diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Arch.des nethack/dat/Arch.des
--- nh_orig/dat/Arch.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Arch.des	2009-10-05 13:36:36.538418118 -0400
@@ -9,6 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Arc-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Arc-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (80,'S'), (16,"human mummy"), (4,'M')
 GEOMETRY:center,center
 MAP
@@ -23,5 +25,5 @@
 ....................}|.|...............|.......+.|.......|}.................
 ....................}|.|...............---------.---------}.................
-....................}|.S.\.............+.................+..................
+....................}|.S...............+.................+..................
 ....................}|.|...............---------.---------}.................
 ....................}|.|...............|.......+.|.......|}.................
@@ -69,4 +71,5 @@
 DOOR:locked,(49,14)
 # Lord Carnarvon
+OBJECT:'\',"throne",(25,10)
 MONSTER:'@',"Lord Carnarvon",(25,10)
 # The treasure of Lord Carnarvon
@@ -118,6 +121,8 @@
 #
 
-MAZE: "Arc-loca",' '
-FLAGS: hardfloor
+LEVEL: "Arc-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (80,'S'), (16,"human mummy"), (4,'M')
 GEOMETRY:center,center
 MAP
@@ -266,5 +271,8 @@
 #
 
-MAZE: "Arc-goal", ' '
+LEVEL: "Arc-goal"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (80,'S'), (16,"human mummy"), (4,'M')
 GEOMETRY:center,center
 MAP
@@ -322,5 +330,5 @@
 ALTAR:(50,14),chaos,altar
 # Objects
-OBJECT:'(',"crystal ball",(50,14),blessed,5,"The Orb of Detection"
+OBJECT:'(',"crystal ball",(50,14),blessed,5,NAME:"The Orb of Detection"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -385,22 +393,30 @@
 
 LEVEL: "Arc-fila"
+MON_GENERATION:86%, (80,'S'), (16,"human mummy"), (4,'M')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'S', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'S', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 OBJECT: random,random,random
 MONSTER: 'S', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -408,37 +424,50 @@
 MONSTER: 'S', random, random
 MONSTER: 'M', "human mummy", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'S', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'S', random, random
+}
 
 RANDOM_CORRIDORS
 
 LEVEL: "Arc-filb"
+MON_GENERATION:86%, (80,'S'), (16,"human mummy"), (4,'M')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'M', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'M', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 OBJECT: random,random,random
 MONSTER: 'M', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -446,15 +475,20 @@
 MONSTER: 'S', random, random
 MONSTER: 'M', "human mummy", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'S', random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'S', random, random
+}
 
 RANDOM_CORRIDORS
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Barb.des nethack/dat/Barb.des
--- nh_orig/dat/Barb.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Barb.des	2009-10-05 13:36:36.536417191 -0400
@@ -9,6 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Bar-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Bar-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"ogre"), (16,'O'), (16,"troll"), (4,'T')
 GEOMETRY:center,center
 MAP
@@ -20,5 +22,5 @@
 ........|...S........|......+...|...PPP.....................................
 ........|----........|......|...|....PP.....................................
-........|.\..........+......-----...........................................
+........|............+......-----...........................................
 ........|----........|...............PP.....................................
 ........|...S........|...-----.......PPP....................................
@@ -59,4 +61,5 @@
 DOOR:open,(28,05)
 # Elder
+OBJECT:'\',"throne",(10,07)
 MONSTER:'@',"Pelias",(10,07)
 # The treasure of Pelias
@@ -99,6 +102,8 @@
 #
 
-MAZE: "Bar-loca",' '
-FLAGS: hardfloor
+LEVEL: "Bar-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"ogre"), (16,'O'), (16,"troll"), (4,'T')
 GEOMETRY:center,center
 MAP
@@ -208,5 +213,8 @@
 #
 
-MAZE: "Bar-goal", ' '
+LEVEL: "Bar-goal"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"ogre"), (16,'O'), (16,"troll"), (4,'T')
 GEOMETRY:center,center
 MAP
@@ -243,5 +251,5 @@
 NON_DIGGABLE:(00,00,75,19)
 # Objects
-OBJECT:'*',"luckstone",(63,04),blessed,0,"The Heart of Ahriman"
+OBJECT:'*',"luckstone",(63,04),blessed,0,NAME:"The Heart of Ahriman"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -305,6 +313,8 @@
 #
 
-MAZE: "Bar-fila" , ' '
-INIT_MAP: '.' , '.' , true , true , unlit , false
+LEVEL: "Bar-fila"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , '.' , true , true , unlit , false
+MON_GENERATION:86%, (64,"ogre"), (16,'O'), (16,"troll"), (4,'T')
 NOMAP
 #
@@ -331,6 +341,8 @@
 MONSTER: 'T', "rock troll", random, hostile
 
-MAZE: "Bar-filb" , ' '
-INIT_MAP: '.' , ' ' , true , true , unlit , true
+LEVEL: "Bar-filb"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , ' ' , true , true , unlit , true
+MON_GENERATION:86%, (64,"ogre"), (16,'O'), (16,"troll"), (4,'T')
 NOMAP
 #
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/bigroom.des nethack/dat/bigroom.des
--- nh_orig/dat/bigroom.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/bigroom.des	2009-09-27 08:09:41.697416886 -0400
@@ -7,5 +7,7 @@
 #
 
-MAZE:"bigrm-1",' '
+LEVEL:"bigrm-1"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -29,4 +31,34 @@
 ---------------------------------------------------------------------------
 ENDMAP
+
+
+IF [75%] {
+   IF [50%] {
+      TERRAIN[75%]:(10,8),horizontal,28, '-', lit
+      TERRAIN[75%]:(37,8),horizontal,28, '-', lit
+      TERRAIN[75%]:(37,3),vertical,6, '|', lit
+      TERRAIN[75%]:(37,9),vertical,6, '|', lit
+   } ELSE {
+      IF [50%] {
+      	 TERRAIN[75%]:(10,8),horizontal,28, 'F', lit
+      	 TERRAIN[75%]:(37,8),horizontal,28, 'F', lit
+      	 TERRAIN[75%]:(37,3),vertical,6, 'F', lit
+      	 TERRAIN[75%]:(37,9),vertical,6, 'F', lit
+      } ELSE {
+      	 TERRAIN[75%]:(10,8),horizontal,28, 'L', lit
+      	 TERRAIN[75%]:(37,8),horizontal,28, 'L', lit
+      	 TERRAIN[75%]:(37,3),vertical,6, 'L', lit
+      	 TERRAIN[75%]:(37,9),vertical,6, 'L', lit
+      }
+   }
+} ELSE {
+   IF [25%] {
+      TERRAIN:(4,4,70,13),unfilled, '-',lit
+      TERRAIN:(25, 4),horizontal,25, '.',lit
+      TERRAIN:(25,13),horizontal,25, '.',lit
+   }
+}
+
+
 # Dungeon Description
 REGION:(01,01,73,16),lit,"ordinary"
@@ -37,59 +69,21 @@
 NON_DIGGABLE:(00,00,74,17)
 # Objects
+LOOP [15] {
 OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
+}
 # Random traps
+LOOP [6] {
 TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
+}
 # Random monsters.
+LOOP [28] {
 MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
+}
 
 #	Here, just play with the lighting...
 
-MAZE:"bigrm-2",' '
+LEVEL:"bigrm-2"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -123,4 +117,19 @@
 REGION:(51,07,73,10),unlit,"ordinary"
 REGION:(51,11,73,16),lit,"ordinary"
+
+
+IF [40%] {
+   RANDLINE:random,random,'L',lit,20
+   IF [50%] {
+      RANDLINE:random,random,'L',lit,25
+   }
+   IF [50%] {
+      RANDLINE:random,random,'L',lit,25,2
+   }
+   IF [25%] {
+      RANDLINE:random,random,'L',lit,25,3
+   }
+}
+
 # Stairs
 STAIR:random,up
@@ -129,59 +138,21 @@
 NON_DIGGABLE:(00,00,74,17)
 # Objects
+LOOP [15] {
 OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
+}
 # Random traps
+LOOP [6] {
 TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
+}
 # Random monsters.
+LOOP [28] {
 MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
+}
 
 #	Now, let's get fancy...
 
-MAZE:"bigrm-3",' '
+LEVEL:"bigrm-3"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -213,26 +184,11 @@
 NON_DIGGABLE:(00,00,74,17)
 # Objects
+LOOP [15] {
 OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
+}
 # Random traps
+LOOP [6] {
 TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
+}
 # Random monsters.
 MONSTER:random,random,(01,01)
@@ -264,5 +220,8 @@
 MONSTER:random,random,(61,16)
 MONSTER:random,random,(73,16)
-MAZE:"bigrm-4",' '
+
+LEVEL:"bigrm-4"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -299,59 +258,21 @@
 FOUNTAIN:(69,15)
 # Objects
+LOOP [15] {
 OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
+}
 # Random traps
+LOOP [6] {
 TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
+}
 # Random monsters.
+LOOP [28] {
 MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
+}
 
 #	Try an oval room...
 
-MAZE:"bigrm-5",' '
+LEVEL:"bigrm-5"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -378,4 +299,14 @@
 # Dungeon Description
 REGION:(00,00,72,18),lit,"ordinary"
+
+IF [33%] {
+   IF [50%] {
+      RANDLINE:(37,0),(37,18),'P',lit,20,2
+   } ELSE {
+      RANDLINE:(0,10),(73,10),'P',lit,20,2
+   }
+}
+
+
 # Stairs
 STAIR:random,up
@@ -383,54 +314,206 @@
 # Non diggable walls
 NON_DIGGABLE:(00,00,72,18)
-# Objects
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
-OBJECT:random,random,random
+
+LOOP [15] {
 OBJECT:random,random,random
-# Random traps
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
+}
+
+LOOP [6] {
 TRAP:random,random
-# Random monsters.
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
-MONSTER:random,random,random
+}
+
+LOOP [28] {
 MONSTER:random,random,random
+}
+
+
+# The Four Circles
+
+LEVEL:"bigrm-6"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+GEOMETRY:center,center
+MAP
+     ---------         ---------         ---------         ---------     
+   ---.......---     ---.......---     ---.......---     ---.......---   
+  --...........--   --...........--   --...........--   --...........--  
+ --.............-- --.............-- --.............-- --.............-- 
+ -...............- -...............- -...............- -...............- 
+|-...............---...............---...............---...............--
+|.................-.................-.................-.................|
+|........T.................T.................T.................T........|
+|.......................................................................|
+|......T.{.....................................................{.T......|
+|.......................................................................|
+|........T.................T.................T.................T........|
+|.................-.................-.................-.................|
+--...............---...............---...............---...............--
+ -...............- -...............- -...............- -...............- 
+ --.............-- --.............-- --.............-- --.............-- 
+  --...........--   --...........--   --...........--   --...........--  
+   ---.......---     ---.......---     ---.......---     ---.......---   
+     ---------         ---------         ---------         ---------     
+ENDMAP
+# Dungeon Description
+REGION:(01,01,72,17),lit,"ordinary"
+# Stairs
+STAIR:random,up
+STAIR:random,down
+# Non diggable walls
+NON_DIGGABLE:(00,00,72,18)
+
+LOOP [15] {
+  OBJECT:random,random,random
+}
+
+LOOP [6] {
+  TRAP:random,random
+}
+
+LOOP [28] {
 MONSTER:random,random,random
+}
+
+
+# Let's tilt it a bit
+
+LEVEL:"bigrm-7"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+GEOMETRY:center,center
+MAP
+                                                        -----              
+                                                ---------...---            
+                                        ---------.........L...---          
+                                ---------.......................---        
+                        ---------.................................---      
+                ---------...........................................---    
+        ---------.....................................................---  
+|--------...............................................................--|
+|.........................................................................|
+|.L.....................................................................L.|
+|.........................................................................|
+|--...............................................................--------|
+  ---.....................................................---------        
+    ---...........................................---------                
+      ---.................................---------                        
+        ---.......................---------                                
+          ---...L.........---------                                        
+            ---...---------                                                
+              -----                                                        
+ENDMAP
+# Dungeon Description
+REGION:(01,01,73,17),lit,"ordinary"
+# Stairs
+STAIR:random,up
+STAIR:random,down
+# Non diggable walls
+NON_DIGGABLE:(00,00,74,18)
+
+LOOP [15] {
+  OBJECT:random,random,random
+}
+
+LOOP [6] {
+  TRAP:random,random
+}
+
+LOOP [28] {
 MONSTER:random,random,random
+}
+
+
+# Two streams
+
+LEVEL:"bigrm-8"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+GEOMETRY:center,center
+MAP
+        |------------------------       -------------------------        
+        |.......................|       |.......................|        
+        |.......................|       |................}}.....|        
+|-------|......}}}}.............|--------.....}}.}.....}}}}.....--------|
+|}}}......}}..}}}}}}..........}}}..........}}}..}.....}....}.}}..}}}}}}}|
+|}}}....}}.}}}.....}....}}...}...}}}....}.}...........}.....}}.}}....}}}|
+|}}}}}}}............}}}}..}}}.......}}}}}}}............}..............}}|
+|}}}}}...............}}...............}}...}............}...........}}}}|
+|-------|.......................|--------...}.........}}}.......--------|
+        |.......................|       |...}}......}}.}........|        
+|--------........LLLL....LL.....--------|....}}...}}............|-------|
+|LLL..........LLL.........LLL......LLL........}.}}}}.......LLL.........L|
+|LLLL........LLL.............L...LL..LLLLLL....}}.}.....LLL...LLL....LLL|
+|LLLLLLLL..LLL.LLLLLL.........LLL......LLLLL.........LLLL........LLLLLLL|
+|LLLLLL..LLL........LLL...LLLL............LLLLL..LLLL.LLLLL........LLLLL|
+|--------..............LLL......--------|.....LLL....LLLLLL.....|-------|
+        |.......................|       |...............LL......|        
+        |.......................|       |.......................|        
+        -------------------------       -------------------------        
+ENDMAP
+# Dungeon Description
+REGION:(01,01,72,17),lit,"ordinary"
+# Stairs
+STAIR:random,up
+STAIR:random,down
+#
+# Non diggable walls
+NON_DIGGABLE:(00,00,72,18)
+
+LOOP [15] {
+  OBJECT:random,random,random
+}
+
+LOOP [6] {
+  TRAP:random,random
+}
+
+LOOP [28] {
 MONSTER:random,random,random
+}
+
+
+# Slanted
+
+LEVEL:"bigrm-9"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+GEOMETRY:center,center
+MAP
+----------------------------------------------                             
+|............................................---                           
+--.............................................---                         
+ ---......................................FF.....---                       
+   ---...................................FF........---                     
+     ---................................FF...........---                   
+       ---.............................FF..............---                 
+         ---..........................FF.................---               
+           ---.......................FF....................---             
+             ---....................FF.......................---           
+               ---.................FF..........................---         
+                 ---..............FF.............................---       
+                   ---...........FF................................----    
+                     ---........FF...................................---   
+                       ---.....FF......................................--- 
+                         ---.............................................--
+                           ---............................................|
+                             ----------------------------------------------
+ENDMAP
+# Dungeon Description
+REGION:(01,01,73,16),lit,"ordinary"
+# Stairs
+STAIR:random,up
+STAIR:random,down
+# Non diggable walls
+NON_DIGGABLE:(00,00,74,17)
+
+LOOP [15] {
+  OBJECT:random,random,random
+}
+
+LOOP [6] {
+  TRAP:random,random
+}
+
+LOOP [28] {
 MONSTER:random,random,random
+}
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/castle.des nethack/dat/castle.des
--- nh_orig/dat/castle.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/castle.des	2009-10-22 15:51:50.237270862 -0400
@@ -16,7 +16,11 @@
 # To motivate the player : there are 4 storerooms (armors, weapons, food and
 # gems) and a wand of wishing in one of the 4 towers...
+#
+# Castle level explicitly marked as graveyard to prevent getting
+# too many wraith corpses from VotD
 
-MAZE:"castle",random
-FLAGS: noteleport
+LEVEL:"castle"
+FLAGS: noteleport,mazelevel,graveyard
+INIT_MAP:mazegrid,'-'
 GEOMETRY:center,center
 MAP
@@ -25,13 +29,13 @@
 }|.....|-----------------------------------------------|.....|}
 }|.....+...............................................+.....|}
-}-------------------------------+-----------------------------}
-}}}}}}|........|..........+...........|.......S.S.......|}}}}}}
+}-FFF---------------------------+-------------------------FFF-}
+}}}}}}|........|..........+...........|.......|.|.......|}}}}}}
 .....}|........|..........|...........|.......|.|.......|}.....
 .....}|........------------...........---------S---------}.....
-.....}|...{....+..........+.........\.S.................+......
+.....}|...{....+..........+...........S.................+......
 .....}|........------------...........---------S---------}.....
 .....}|........|..........|...........|.......|.|.......|}.....
-}}}}}}|........|..........+...........|.......S.S.......|}}}}}}
-}-------------------------------+-----------------------------}
+}}}}}}|........|..........+...........|.......|.|.......|}}}}}}
+}-FFF---------------------------+-------------------------FFF-}
 }|.....+...............................................+.....|}
 }|.....|-----------------------------------------------|.....|}
@@ -40,4 +44,17 @@
 ENDMAP
 
+# Treasure room 1
+RANDOM_PLACES:(46,05),(44,07),(38,06),(40,04)
+TERRAIN:place[0],'S',lit
+# Treasure room 2
+RANDOM_PLACES:(48,05),(54,07),(51,04)
+TERRAIN:place[0],'S',lit
+# Treasure room 3
+RANDOM_PLACES:(46,11),(44,12),(38,11),(40,09)
+TERRAIN:place[0],'S',lit
+# Treasure room 4
+RANDOM_PLACES:(48,11),(54,09),(51,12)
+TERRAIN:place[0],'S',lit
+
 # Random registers initialisation
 RANDOM_OBJECTS:'[',')','*','%'
@@ -46,14 +63,15 @@
 
 TELEPORT_REGION:levregion(01,00,10,20),(1,1,61,15),down
-TELEPORT_REGION:levregion(69,00,79,20),(1,1,61,15),up
+TELEPORT_REGION:levregion(69,00,77,20),(1,1,61,15),up
 STAIR:levregion(01,00,10,20),(0,0,62,16),up
+BRANCH:levregion(69,00,77,20),(1,1,61,15)
 FOUNTAIN:(10,08)
 # Doors
-DOOR:closed,(07,03)
-DOOR:closed,(55,03)
+DOOR:locked,(07,03)
+DOOR:locked,(55,03)
 DOOR:locked,(32,04)
 DOOR:locked,(26,05)
-DOOR:locked,(46,05)
-DOOR:locked,(48,05)
+# DOOR:locked,(46,05)
+# DOOR:locked,(48,05)
 DOOR:locked,(47,07)
 DOOR:closed,(15,08)
@@ -63,9 +81,9 @@
 DOOR:locked,(47,09)
 DOOR:locked,(26,11)
-DOOR:locked,(46,11)
-DOOR:locked,(48,11)
+# DOOR:locked,(46,11)
+# DOOR:locked,(48,11)
 DOOR:locked,(32,12)
-DOOR:closed,(07,13)
-DOOR:closed,(55,13)
+DOOR:locked,(07,13)
+DOOR:locked,(55,13)
 # The drawbridge
 DRAWBRIDGE:(05,08),east,closed
@@ -131,10 +149,27 @@
 OBJECT:object[3],random,(55,11)
 # THE WAND OF WISHING in 1 of the 4 towers
-CONTAINER:'(',"chest",place[0]
-OBJECT:'/',"wishing",contained
-# Prevent monsters from eating it.  (@'s never eat objects)
+CONTAINER:'(',"chest",place[0] {
+  OBJECT:'/',"wishing"
+}
+# THE NOT QUITE WANDS OF WISHING
+# ...since you can see the chest now through the bars,
+# we have to find a better way to disguise where the wand is
+CONTAINER:'(',"chest",place[1] {
+  OBJECT:'/',"secret door detection"
+}
+CONTAINER:'(',"chest",place[2] {
+  OBJECT:'/',random
+}
+CONTAINER:'(',"chest",place[3] {
+  OBJECT:'/',random
+}
+# Prevent monsters from eating them.  (@'s never eat objects)
 ENGRAVING:place[0],burn,"Elbereth"
+ENGRAVING:place[1],burn,"Elbereth"
+ENGRAVING:place[2],burn,"Elbereth"
+ENGRAVING:place[3],burn,"Elbereth"
 # The treasure of the lord
 OBJECT:'(',"chest",(37,08)
+OBJECT:'\',"throne",(36,08)
 # Traps
 TRAP:"trap door",(40,08)
@@ -154,12 +189,12 @@
 MONSTER:'@',"lieutenant",(09,08)
 # Soldiers guarding the towers
-MONSTER:'@',"soldier",(03,02)
-MONSTER:'@',"soldier",(05,02)
-MONSTER:'@',"soldier",(57,02)
-MONSTER:'@',"soldier",(59,02)
-MONSTER:'@',"soldier",(03,14)
-MONSTER:'@',"soldier",(05,14)
-MONSTER:'@',"soldier",(57,14)
-MONSTER:'@',"soldier",(59,14)
+MONSTER:'@',"sergeant",(03,02)
+MONSTER:'@',"sergeant",(05,02)
+MONSTER:'@',"sergeant",(57,02)
+MONSTER:'@',"sergeant",(59,02)
+MONSTER:'@',"sergeant",(03,14)
+MONSTER:'@',"sergeant",(05,14)
+MONSTER:'@',"sergeant",(57,14)
+MONSTER:'@',"sergeant",(59,14)
 # The four dragons that are guarding the storerooms
 MONSTER:'D',random,(47,05)
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Caveman.des nethack/dat/Caveman.des
--- nh_orig/dat/Caveman.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Caveman.des	2009-09-29 16:12:36.779293215 -0400
@@ -9,29 +9,40 @@
 #	and receive your quest assignment.
 #
-MAZE: "Cav-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Cav-strt"
+FLAGS: noteleport,hardfloor,arboreal,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"tiger"), (16,'S'), (16,"ape"), (4,'f')
 GEOMETRY:center,center
 MAP
                                                                             
-  ......     ..........................       ...        ....  ......       
- ......       ..........................     ........       ....    .....   
-  ..BB      .............................    .........            ....  ..  
-     ..    ......................              .......      ..     ....  .. 
-     ..     ....................                     ..  .......    ..  ... 
-   ..              S   BB                .....     .......   ....      .... 
-    ..        ...  .   ..               ........  ..     ..   ..       ...  
-     ..      ......     ..             ............       ..          ...   
-       .      ....       ..             ........           ..  ...........  
-  ...   ..     ..        .............                  ................... 
- .....   .....            ...............................      ...........  
-  .....B................            ...                               ...   
-  .....     .  ..........        .... .      ...  ..........           ...  
-   ...     ..          .............  ..    ...................        .... 
-          BB       ..   .........      BB    ...  ..........  ..   ...  ... 
-       ......    .....  B          ........         ..         .. ....  ... 
-     ..........  ..........         ..... ...      .....        ........    
-       ..  ...    .  .....         ....    ..       ...            ..       
+  ......     ..........................       ... PP   P ....  ...... P     
+ ......       ..........................     .......P    PP .... PP .....P  
+  ..BB      ............................    P...P P...P      .P  P....  ..  
+     ..    ......................             P.......P  PP .. P  P....P .. 
+     ..  P BB...................         PP          ..  .......P  P.. P... 
+   ...   ...B      B                     ..... P  P....... PP....   PP .... 
+    ..P P.    ...  .  ...               ...P....P ..  PP ..   .. P     P..  
+     ..  .P  .......  ....            P...PPP...... P    PPPP P    PP ...   
+  PPP .. .    ....   ... . PP  P      P ........  P   P  P ..  ...........  
+  ... P...     ..   .... .B...........P  PP  PP  PP P  P.........PP........ 
+ .....  P.....             ..............................  PP  ...........P 
+P .PP..B..........PPP...   P  PPP   ... P P PPP  P  P PP     P  PPP   ...   
+  .....  PP .  ..........PP  PPP ....P.PP    ...  .......... PP       P...  
+  P...P    ..    PPP   .............  ..   P.........PPPP......     P P.... 
+          BB            .........PP    BB    ...  .....P....P .. PP... P... 
+       ......    .....  B     PP    .......   P PP P.. PPP   PP.. .P..  ... 
+     ..........  ..........        ...... ..      P.....   P    .........P  
+       ..  ...    .  .....         ....    ..       ...P       P   ..  P    
                                                                             
 ENDMAP
+
+REPLACE_TERRAIN:(40,1, 74,18), 'P', ' ', unlit, 25%
+REPLACE_TERRAIN:(40,1, 74,18), 'P', '.', unlit, 5%
+
+IF [90%] {
+   TERRAIN:(43,11),' ',unlit
+   TERRAIN:(40,10),'.',unlit
+}
+
 # Dungeon Description
 REGION:(00,00,75,19),unlit,"ordinary"
@@ -43,11 +54,9 @@
 REGION:(05,17,14,18),lit,"ordinary",unfilled,true
 REGION:(17,16,23,18),lit,"ordinary",unfilled,true
-REGION:(35,16,44,18),lit,"ordinary",unfilled,true
+REGION:(37,16,44,18),lit,"ordinary",unfilled,true
 # Stairs
-STAIR:(02,03),down
+LADDER:(02,03),down
 # Portal arrival point
 BRANCH:(71,09,71,09),(0,0,0,0)
-# Doors
-DOOR:locked,(19,06)
 # The temple altar (this will force a priest(ess) to be created)
 ALTAR:(36,02),coaligned,shrine
@@ -64,28 +73,52 @@
 MONSTER:'@',"neanderthal",(21,01)
 MONSTER:'@',"neanderthal",(22,01)
-MONSTER:'@',"neanderthal",(26,09)
+MONSTER:'@',"neanderthal",(24,08)
 # Non diggable walls
 NON_DIGGABLE:(00,00,75,19)
 # Random traps
-TRAP:"pit",(47,11)
-TRAP:"pit",(57,10)
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-# Monsters on siege duty (in the outer caves).
-MONSTER: 'h',"bugbear",(47,02),hostile
-MONSTER: 'h',"bugbear",(48,03),hostile
-MONSTER: 'h',"bugbear",(49,04),hostile
-MONSTER: 'h',"bugbear",(67,03),hostile
-MONSTER: 'h',"bugbear",(69,04),hostile
-MONSTER: 'h',"bugbear",(51,13),hostile
-MONSTER: 'h',"bugbear",(53,14),hostile
-MONSTER: 'h',"bugbear",(55,15),hostile
-MONSTER: 'h',"bugbear",(63,10),hostile
-MONSTER: 'h',"bugbear",(65,09),hostile
-MONSTER: 'h',"bugbear",(67,10),hostile
-MONSTER: 'h',"bugbear",(69,11),hostile
-WALLIFY
+TRAP:"pit",random
+TRAP:"pit",random
+TRAP:"pit",random
+TRAP:"spiked pit",random
+TRAP:"spiked pit",random
+TRAP:"spiked pit",random
+TRAP:"bear",(19,13)
+TRAP:"bear",(46,11)
+TRAP:"bear",random
+TRAP:"bear",random
+TRAP:"bear",random
+TRAP:"bear",random
+# Random jungle stuff
+MONSTER: ';',"giant eel",random,hostile
+MONSTER: ';',"giant eel",random,hostile
+MONSTER: ';',"giant eel",random,hostile
+MONSTER: ';',"giant eel",random,hostile
+MONSTER: ';',"giant eel",random,hostile
+MONSTER: ';',"giant eel",random,hostile
+MONSTER: ';',"giant eel",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"monkey",random,hostile
+MONSTER: 'Y',"ape",random,hostile
+MONSTER: 'Y',"ape",random,hostile
+MONSTER: 'Y',"ape",random,hostile
+MONSTER: 'Y',"ape",random,hostile
+MONSTER: 'Y',"ape",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'f',"panther",random,hostile
+MONSTER: 'f',"panther",random,hostile
+MONSTER: 'f',"panther",random,hostile
+MONSTER: 'f',"panther",random,hostile
 
 #
@@ -96,37 +129,40 @@
 #
 
-MAZE: "Cav-loca",' '
-FLAGS: hardfloor
+LEVEL: "Cav-loca"
+FLAGS: noteleport,hardfloor,arboreal,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"tiger"), (16,'S'), (16,"ape"), (4,'f')
 GEOMETRY:center,center
 MAP
                                                                             
     .............                     ...........                           
-   ...............                   .............                          
-    .............                  ...............        ..........        
-     ...........                    .............      ...............      
-        ...                                    ...   ..................     
-         ...                ..........          ... ..................      
-          ...              ............          BBB...................     
+   ........PPP....                   .............                          
+    ......PPP....                  ...............        ..........        
            ...              ..........          ......................      
-            .....                 ..      .....B........................    
-  ....       ...............      .    ........B..........................  
- ......     .. .............S..............         ..................      
-  ....     ..                ...........             ...............        
-     ..  ...                                    ....................        
+        ....  PP                               ...   ..................     
+         ...                ..........          ... ..................      
+         P...              ....PPP.....          BBB...................     
+           ... P            ..........          ......................      
+   PP       ..... PP   P          ..      ....PB........................    
+  ....       ...............      .  P .......PB..........................  
+ ......     .. .............P..............         ..................      
+  ....     ..  P   PPP       ...........             ...............        
+     ..  ...                      PPP           ....................        
       ....                                      BB...................       
-         ..                 ..                 ..  ...............          
-          ..   .......     ....  .....  ....  ..     .......   S            
-           ............     ....... ..  .......       .....    ...  ....    
-               .......       .....   ......                      .......    
+      PP .. P               ..                 ..  ...............          
+          ..   .......     ....  .....  ....  ..     .......   P            
+         P ......PPP...     ....... ..  .......       .....    ...  ....    
+            P  .......       .....   ......                      .......    
                                                                             
 ENDMAP
+
+REPLACE_TERRAIN:(00,00,25,19), ' ', 'P', unlit, 10%
+
 # Dungeon Description
 REGION:(00,00,75,19),unlit,"ordinary"
 REGION:(52,06,73,15),lit,"ordinary",unfilled,true
-# Doors
-DOOR:locked,(28,11)
 # Stairs
-STAIR:(04,03),up
-STAIR:(73,10),down
+LADDER:(04,03),up
+LADDER:(73,10),down
 # Non diggable walls
 NON_DIGGABLE:(00,00,75,19)
@@ -148,39 +184,40 @@
 OBJECT:random,random,random
 # Random traps
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-TRAP:random,random
-# Random monsters.
-MONSTER:'h',"bugbear",(02,10),hostile
-MONSTER:'h',"bugbear",(03,11),hostile
-MONSTER:'h',"bugbear",(04,12),hostile
-MONSTER:'h',"bugbear",(02,11),hostile
-MONSTER:'h',"bugbear",(16,16),hostile
-MONSTER:'h',"bugbear",(17,17),hostile
-MONSTER:'h',"bugbear",(18,18),hostile
-MONSTER:'h',"bugbear",(19,16),hostile
-MONSTER:'h',"bugbear",(30,06),hostile
-MONSTER:'h',"bugbear",(31,07),hostile
-MONSTER:'h',"bugbear",(32,08),hostile
-MONSTER:'h',"bugbear",(33,06),hostile
-MONSTER:'h',"bugbear",(34,07),hostile
-MONSTER:'h',"bugbear",random,hostile
-MONSTER:'h',"bugbear",random,hostile
-MONSTER:'h',"bugbear",random,hostile
-MONSTER:'h',"bugbear",random,hostile
-MONSTER:'h',random,random,hostile
-MONSTER:'H',random,random,hostile
-MONSTER:'H',"hill giant",(03,12),hostile
-MONSTER:'H',"hill giant",(20,17),hostile
-MONSTER:'H',"hill giant",(35,08),hostile
-MONSTER:'H',"hill giant",random,hostile
-MONSTER:'H',"hill giant",random,hostile
-MONSTER:'H',"hill giant",random,hostile
-MONSTER:'H',"hill giant",random,hostile
-MONSTER:'H',random,random,hostile
-WALLIFY
+TRAP:"spiked pit",random
+TRAP:"spiked pit",random
+TRAP:"spiked pit",random
+TRAP:"spiked pit",random
+TRAP:"bear",random
+TRAP:"bear",random
+TRAP:"bear",random
+TRAP:"bear",random
+TRAP:"bear",random
+TRAP:"bear",random
+# Monsters...
+MONSTER:';',"electric eel",(28,11),hostile
+MONSTER:';',"electric eel",(46,09),hostile
+MONSTER:';',"electric eel",(46,10),hostile
+MONSTER:';',"electric eel",(63,16),hostile
+MONSTER:';',"giant eel",random,hostile
+MONSTER:';',"giant eel",random,hostile
+MONSTER:';',"giant eel",random,hostile
+MONSTER:';',"giant eel",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"monkey",random,hostile
+MONSTER:'Y',"monkey",random,hostile
+MONSTER:'Y',"monkey",random,hostile
+MONSTER:'Y',"monkey",random,hostile
+MONSTER:'S',"python",random,hostile
+MONSTER:'S',"python",random,hostile
+MONSTER:'S',"python",random,hostile
+MONSTER:'S',"python",random,hostile
+# WALLIFY
 
 #
@@ -192,5 +229,8 @@
 #
 
-MAZE: "Cav-goal", ' '
+LEVEL: "Cav-goal"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"tiger"), (16,'S'), (16,"ape"), (4,'f')
 GEOMETRY:center,center
 MAP
@@ -219,9 +259,9 @@
 REGION:(00,00,75,19),lit,"ordinary"
 # Stairs
-STAIR:random,up
+LADDER:random,up
 # Non diggable walls
 NON_DIGGABLE:(00,00,75,19)
 # Objects
-OBJECT:')',"mace",(23,10),blessed,0,"The Sceptre of Might"
+OBJECT:')',"mace",(23,10),blessed,0,NAME:"The Sceptre of Might"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -243,21 +283,51 @@
 MONSTER:'F',"shrieker",(25,8)
 MONSTER:'F',"shrieker",(45,11)
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'Y',"carnivorous ape",random,hostile
+MONSTER:'f',"tiger",random,hostile
+MONSTER:'f',"tiger",random,hostile
+MONSTER:'f',"tiger",random,hostile
 WALLIFY
 
 #
-#	The "fill" levels for the quest.
-#
-#	These levels are used to fill out any levels not occupied by specific
-#	levels as defined above. "filla" is the upper filler, between the
-#	start and locate levels, and "fillb" the lower between the locate
-#	and goal levels.
+#	The level inbetween the original starting jungle and the lower levels
+#	where the actual caves are.
 #
 
-MAZE: "Cav-fila" , ' '
-INIT_MAP: '.' , ' ' , true , true , random , true
-NOMAP
+LEVEL: "Cav-fila"
+FLAGS: noteleport,hardfloor,arboreal,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"tiger"), (16,'S'), (16,"ape"), (4,'f')
+GEOMETRY: center,center
+MAP
+                                                                            
+                                          P                                 
+                                         PP                                 
+    ...                ....             .PP...            P  ....           
+   .....              ..PP...       ....PP.......          ........         
+   .....             ...PP...      .....PPP.........   P ..........         
+   .......           ........      .....PP..........................        
+     .....           .........      ...PPP............ P    ....P...        
+     ..P..         .....  ....       ..PP...     PPP        ...PPP..        
+     ..PP.         ....    ....       PPP                  P...PPP..        
+      .....        ...      ...       PP                    ....P...        
+      .....        ..       ...       P                    .........P       
+       ..... P     ..        ...                         ...........        
+       ......      ..        ...                  ..................        
+       ......      ..         .. P   PPP   .........PPPP...........P        
+        P  ...  PP ..         ..............................   PP           
+            ........               PPP    P   ..........                    
+             PPP                                                            
+                                                                            
+                                                                            
+ENDMAP
 #
-STAIR: random, up
-STAIR: random, down
+LADDER: (05,04), up
+LADDER: (36,05), down
+#
+REGION:(00,00,75,19),unlit,"ordinary"
+#
+NON_DIGGABLE:(00,00,75,19)
 #
 OBJECT: random, random, random
@@ -269,23 +339,52 @@
 OBJECT: random, random, random
 #
-TRAP: random, random
-TRAP: random, random
-TRAP: random, random
-TRAP: random, random
+TRAP: "pit", random
+TRAP: "pit", random
+TRAP: "pit", random
+TRAP: "spiked pit", random
+TRAP: "spiked pit", random
+TRAP: "spiked pit", random
+TRAP: "bear", (37,15)
+TRAP: "bear", random
+TRAP: "bear", random
+TRAP: "bear", random
 #
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', random, random, hostile
-MONSTER: 'H', "hill giant", random, hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
 
-MAZE: "Cav-filb" , ' '
-INIT_MAP: '.' , ' ' , true , true , random , true
+#
+#	The "fill" levels for the quest.
+#
+#	These levels are used to fill out any levels not occupied by specific
+#	levels as defined above. "filla" is the upper filler, between the
+#	start and locate levels, and "fillb" the lower between the locate
+#	and goal levels.
+#	
+#	Obviously, "fila" has been hijacked and moved above.  :)
+#
+
+LEVEL: "Cav-filb"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , ' ' , true , true , random , true
+MON_GENERATION:86%, (64,"tiger"), (16,'S'), (16,"ape"), (4,'f')
 NOMAP
 #
-STAIR: random, up
-STAIR: random, down
+LADDER: random, up
+LADDER: random, down
 #
 OBJECT: random, random, random
@@ -302,15 +401,31 @@
 OBJECT: random, random, random
 #
-TRAP: random, random
-TRAP: random, random
-TRAP: random, random
-TRAP: random, random
+TRAP: "pit", random
+TRAP: "pit", random
+TRAP: "pit", random
+TRAP: "spiked pit", random
+TRAP: "spiked pit", random
+TRAP: "spiked pit", random
+TRAP: "bear", random
+TRAP: "bear", random
+TRAP: "bear", random
+TRAP: "bear", random
 #
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', "bugbear", random, hostile
-MONSTER: 'h', random, random, hostile
-MONSTER: 'h', random, random, hostile
-MONSTER: 'H', "hill giant", random, hostile
-MONSTER: 'H', "hill giant", random, hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'f',"tiger",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'S',"python",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+MONSTER: 'Y',"carnivorous ape",random,hostile
+
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/dungeon.def nethack/dat/dungeon.def
--- nh_orig/dat/dungeon.def	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/dungeon.def	2009-10-22 15:53:21.667272739 -0400
@@ -22,11 +22,11 @@
 LEVALIGN:	neutral
 CHAINBRANCH:	"Sokoban" "oracle" + (1, 0) up
-RNDLEVEL:	"bigrm" "B" @ (10, 3) 40 5
+RNDLEVEL:	"bigrm" "B" @ (10, 3) 40 9
 CHAINBRANCH:	"The Quest" "oracle" + (6, 2) portal
 BRANCH:		"Fort Ludios" @ (18, 4) portal
-RNDLEVEL:	"medusa" "none" @ (-5, 4) 2
+RNDLEVEL:	"medusa" "none" @ (-5, 4) 4
 LEVALIGN:	chaotic
 LEVEL:		"castle" "none" @ (-1, 0)
-CHAINBRANCH:	"Gehennom" "castle" + (0, 0) no_down
+CHAINBRANCH:	"Gehennom" "castle" + (0, 0) down
 BRANCH:		"The Elemental Planes" @ (1, 0) no_down up
 
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/endgame.des nethack/dat/endgame.des
--- nh_orig/dat/endgame.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/endgame.des	2009-09-29 16:12:36.752417876 -0400
@@ -10,6 +10,7 @@
 # shrine.
 
-MAZE:"earth",' '
-FLAGS: noteleport,hardfloor,shortsighted
+LEVEL:"earth"
+FLAGS: noteleport,hardfloor,shortsighted,mazelevel
+INIT_MAP:solidfill,' '
 MESSAGE: "Well done, mortal!"
 MESSAGE: "But now thou must face the final Test..."
@@ -44,6 +45,11 @@
                                                                             
 ENDMAP
+
+REPLACE_TERRAIN:(0,0,75,19), ' ', '.', unlit, 15%
+
+
 #  Since there are no stairs, this forces the hero's initial placement
 TELEPORT_REGION:(69,16,69,16),(0,0,0,0)
+TERRAIN:(69,16),'.',lit
 PORTAL:(0,0,75,19),(65,13,75,19),"air"
 #  Some helpful monsters.  Making sure a
@@ -125,6 +131,7 @@
 
 
-MAZE:"air",' '
-FLAGS: noteleport,hardfloor,shortsighted
+LEVEL:"air"
+FLAGS: noteleport,hardfloor,shortsighted,mazelevel,stormy
+INIT_MAP:solidfill,' '
 # The following messages are somewhat obtuse, to make then
 # equally meaningful if the player can see or not.
@@ -138,25 +145,29 @@
 # is all "air".
 MAP
-AAAAAAAAAAAAAAAAAAAAAAAACCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAACCCCCCAAAAAAAACCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAACCAACCCCCAAAAAACCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAACCACCCCCCCAAAAACCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAACCCCCCCCCCAAAAACCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAACCCCAAACCAAACCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAACCCCAAAAAACCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAACCCCCCCAAAACCACCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAACCCCAAAAAAACCACAACCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCAACCCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAACCCCAAACCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACACACCCCCAAACCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAACAACCCCCCCAAAACCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACACCCCCCCCAAACCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCCCCCAACCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAACACCCCCCCCCCACCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAACAACCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAACCCCCCAAACCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAACCAAAAAACCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 ENDMAP
+
+REPLACE_TERRAIN:(0,0,75,19), 'A', 'C', lit, 35%
+REPLACE_TERRAIN:(25,0,50,19), 'A', 'C', lit, 50%
+
 # Use up and down regions to partition the level into three parts;
 # teleportation can't cross from one part into another.
@@ -226,6 +237,7 @@
 
 
-MAZE:"fire",' '
-FLAGS: noteleport,hardfloor,shortsighted
+LEVEL:"fire"
+FLAGS: noteleport,hardfloor,shortsighted,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 # The player lands, upon arrival, in the
@@ -256,5 +268,8 @@
 .................................LL....................LL...................
 ENDMAP
+
+REPLACE_TERRAIN:(0,0,75,19), '.', 'L', lit, 30%
 TELEPORT_REGION:(69,16,69,16),(0,0,0,0)
+TERRAIN:(69,16),'.',lit
 PORTAL:(0,0,75,19),(65,13,75,19),"water"
 
@@ -377,6 +392,7 @@
 
 
-MAZE:"water",' '
-FLAGS: noteleport,hardfloor,shortsighted
+LEVEL:"water"
+FLAGS: noteleport,hardfloor,shortsighted,mazelevel,shroud
+INIT_MAP:solidfill,' '
 MESSAGE: "You find yourself suspended in an air bubble surrounded by water."
 GEOMETRY:center,center
@@ -474,6 +490,7 @@
 
 
-MAZE:"astral",' '
-FLAGS: noteleport,hardfloor,nommap,shortsighted
+LEVEL:"astral"
+FLAGS: noteleport,hardfloor,nommap,shortsighted,mazelevel
+INIT_MAP:solidfill,' '
 MESSAGE: "You arrive on the Astral Plane!"
 MESSAGE: "Here the High Temples of the aligned gods are located."
@@ -540,5 +557,7 @@
 MONSTER:'A',"Angel",(20,09),noalign,hostile
 MONSTER:'A',"Angel",(20,10),noalign,hostile
-MONSTER:'&',"Pestilence",place[0],hostile
+MONSTER:'&',"Pestilence",place[0],hostile {
+  OBJECT:'!',"sickness"
+}
 # South-central round room
 MONSTER:'@',"aligned priest",(36,12),noalign,hostile
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/functions.des nethack/dat/functions.des
--- nh_orig/dat/functions.des	1969-12-31 19:00:00.000000000 -0500
+++ nethack/dat/functions.des	2009-10-17 10:45:04.637430539 -0400
@@ -0,0 +1,21 @@
+
+FUNCTION soko_loot()
+{
+  # Random objects
+  OBJECT:'%',random,random
+  OBJECT:'%',random,random
+  OBJECT:'%',random,random
+  OBJECT:'%',random,random
+  OBJECT:'=',random,random
+  OBJECT:'/',random,random
+}
+
+FUNCTION soko_prize()
+{
+  IF [50%] {
+    OBJECT:'"',"amulet of reflection",place[0]
+  } ELSE {
+    OBJECT:'(',"bag of holding",place[0]
+  }
+  ENGRAVING:place[0],burn,"Elbereth"
+}
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/gehennom.des nethack/dat/gehennom.des
--- nh_orig/dat/gehennom.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/gehennom.des	2009-10-23 09:31:39.053286804 -0400
@@ -5,7 +5,10 @@
 #
 
-MAZE: "valley", ' '
-FLAGS: noteleport,hardfloor,nommap
+LEVEL: "valley"
+FLAGS: noteleport,hardfloor,nommap,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
+#         1         2         3         4         5         6         7
+#123456789012345678901234567890123456789012345678901234567890123456789012345
 MAP
 ----------------------------------------------------------------------------
@@ -13,28 +16,53 @@
 |---|.|.--.---.|  |......--- ----..........-----.-----....---........---.-.|
 |   |.|.|..| |.| --........| |.............|   |.......---| |-...........--|
-|   |...S..| |.| |.......-----.......------|   |--------..---......------- |
-|----------- |.| |-......| |....|...-- |...-----................----       |
-|.....S....---.| |.......| |....|...|  |..............-----------          |
-|.....|.|......| |.....--- |......---  |....---.......|                    |
-|.....|.|------| |....--   --....-- |-------- ----....---------------      |
-|.....|--......---BBB-|     |...--  |.......|    |..................|      |
-|..........||........-|    --...|   |.......|    |...||.............|      |
-|.....|...-||-........------....|   |.......---- |...||.............--     |
+|   |...S..| |.| |.......-----.......------|   |--------..--|......--...-- |
+|----------- |.| |-......| |....|...-- |...-----................----|...|  |
+|.....S....---.| |.......| |....|...|  |..............-----------   |...|  |
+|.....|.|......| |.....--- |......---  |....---.......|            -|...|  |
+|.....|.|------| |....--   --....-- |-------- ----BBBB--------------...--  |
+|.....|--......---BBB-|     |...--  |.......|    |...............B.....|   |
+|..........||........-|    --...|   |.......|    |...||..........B..----   |
+|.....|....||.........------....|   |.......---- |...||..........B..--     |
 |.....|--......---...........--------..........| |.......---------...--    |
 |.....| |------| |--.......--|   |..B......----- -----....| |.|  |....---  |
 |.....| |......--| ------..| |----..B......|       |.--------.-- |-.....---|
-|------ |........|  |.|....| |.....----BBBB---------...........---.........|
-|       |........|  |...|..| |.....|  |-.............--------...........---|
-|       --.....-----------.| |....-----.....----------     |.........----  |
-|        |..|..B...........| |.|..........|.|              |.|........|    |
+|-------|........|  |.|....| |.....----BBBB---------...........---.........|
+||....B.S........|  |...|..| |.....|  |-.............--------...........---|
+||....--|-.....-----------.| |....-----.....----------     |......... ---  |
+||....-  |..|..B...........| |.|..........|.|              |.|........|    |
 ----------------------------------------------------------------------------
 ENDMAP
+
+IF [50%] {
+   TERRAIN:(50,8),horizontal,4, '-',unlit
+   TERRAIN:(40,8),horizontal,4, 'B',unlit
+}
+
+IF [50%] {
+   TERRAIN:(27,12),'|',unlit
+   TERRAIN:(27,3),horizontal,3, 'B',unlit
+   TERRAIN:(28,2), '-',unlit
+}
+
+IF [50%] {
+	TERRAIN:(60,5),'|',unlit
+} ELSE {
+	TERRAIN:(68,8),vertical,2,'|',unlit
+}
+
+IF [50%] {
+   TERRAIN:(16,10),vertical,2,'|',unlit
+   TERRAIN:(9,13),horizontal,6, 'B',unlit
+}
+
 # Dungeon Description
 # The shrine to Moloch.
-REGION:(01,06,05,14),lit,"temple"
+REGION:(01,06,05,14),unlit,"temple"
 # The Morgues
 REGION:(19,01,24,08),unlit,"morgue",filled,true
 REGION:(09,14,16,18),unlit,"morgue",filled,true
 REGION:(37,09,43,14),unlit,"morgue",filled,true
+REGION:(50,09,64,11),unlit,"morgue",filled,true
+REGION:(02,16,05,18),unlit,"morgue",filled,true
 # Stairs
 STAIR:(01,01),down
@@ -47,8 +75,13 @@
 DOOR:locked,(08,04)
 DOOR:locked,(06,06)
+DOOR:locked,(08,16)
 
 # The altar of Moloch.
 ALTAR:(03,10),noalign,shrine
 
+# Two sort-of light sources
+OBJECT:'\\',"brazier",(03,06)
+OBJECT:'\\',"brazier",(03,14)
+
 # Non diggable walls - everywhere!
 NON_DIGGABLE:(00,00,75,19)
@@ -113,4 +146,19 @@
 OBJECT:'(',random,random
 OBJECT:'(',random,random
+#
+# Some less random loot.
+#
+CONTAINER:'(',"iron safe",(02,18) {
+	OBJECT:'*',"diamond"
+	OBJECT:'*',"diamond"
+	OBJECT:'*',random
+	OBJECT:'*',random
+	OBJECT:'=',random
+	OBJECT:'=',random
+	OBJECT:'+',random
+	OBJECT:'+',random
+}
+OBJECT:'(',"chest",(02,17)
+OBJECT:'(',"chest",(03,18)
 
 # (Not so) Random traps.
@@ -120,6 +168,6 @@
 TRAP:"board", (21,12)
 TRAP:"board", random
-TRAP:"dart", (60,01)
-TRAP:"dart", (26,17)
+TRAP:"magic", (60,01)
+TRAP:"board", (26,17)
 TRAP:"anti magic", random
 TRAP:"anti magic", random
@@ -156,7 +204,7 @@
 # The Juiblex level
 #
-MAZE:"juiblex",' '
-FLAGS:noteleport,shortsighted
-INIT_MAP:'.','}',true,true,unlit,false
+LEVEL:"juiblex"
+FLAGS:noteleport,shortsighted,mazelevel
+INIT_MAP:mines,'.','}',true,true,unlit,false
 # guarantee at least one open spot to ensure successful stair placement
 GEOMETRY:left,bottom
@@ -273,6 +321,7 @@
 # The Orcus Level
 #
-MAZE:"orcus",random
-FLAGS: noteleport,shortsighted
+LEVEL:"orcus"
+FLAGS: noteleport,shortsighted,mazelevel
+INIT_MAP:mazegrid,'-'
 GEOMETRY:right,center
 # A ghost town
@@ -328,4 +377,9 @@
 OBJECT:'`',"boulder",(15,13)
 OBJECT:'`',"boulder",(14,14)
+# Special rooms
+ALTAR:(24,07),noalign,sanctum
+REGION:(22,12,25,16),unlit,"morgue"
+REGION:(32,09,37,12),lit,"shop"
+REGION:(12,00,15,04),lit,"shop"
 # Doors
 DOOR:closed,(23,02)
@@ -345,9 +399,4 @@
 DOOR:open,(26,14)
 DOOR:closed,(06,15)
-# Special rooms
-ALTAR:(24,07),noalign,sanctum
-REGION:(22,12,25,16),unlit,"morgue"
-REGION:(32,09,37,12),lit,"shop"
-REGION:(12,00,15,04),lit,"shop"
 # Some traps.
 TRAP:"spiked pit", random
@@ -371,5 +420,7 @@
 OBJECT:random,random,random
 # The resident nasty
-MONSTER:'&',"Orcus",(33,15)
+MONSTER:'&',"Orcus",(33,15) {
+  OBJECT:'/',"death"
+}
 # And its preferred companions
 MONSTER:'Z',"human zombie",(32,15)
@@ -413,6 +464,7 @@
 # The Asmodeus Level
 #
-MAZE:"asmodeus",random
-FLAGS: noteleport
+LEVEL:"asmodeus"
+FLAGS: noteleport,mazelevel
+INIT_MAP:mazegrid,'-'
 # First part
 GEOMETRY:half-left,center
@@ -446,5 +498,8 @@
 REGION:(01,01,20,10),unlit,"ordinary"
 # The fellow in residence
-MONSTER:'&',"Asmodeus",(12,07)
+MONSTER:'&',"Asmodeus",(12,07) {
+  OBJECT:'/',"cold"
+  OBJECT:'/',"fire"
+}
 # Some random weapons and armor.
 OBJECT:'[',random,random
@@ -497,6 +552,7 @@
 # The Baalzebub level
 #
-MAZE:"baalz",random
-FLAGS: noteleport
+LEVEL:"baalz"
+FLAGS: noteleport,mazelevel
+INIT_MAP:mazegrid,'-'
 GEOMETRY:right,center
 MAP
@@ -554,7 +610,10 @@
 # The Sanctum Level
 #
-MAZE:"sanctum", ' '
-FLAGS: noteleport,hardfloor,nommap
+LEVEL:"sanctum"
+FLAGS: noteleport,hardfloor,nommap,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
+#         1         2         3         4         5         6         7
+#123456789012345678901234567890123456789012345678901234567890123456789012345
 MAP
 ----------------------------------------------------------------------------
@@ -591,4 +650,9 @@
 DOOR:closed,(46,12)
 DOOR:closed,(53,10)
+# Some mood lighting
+OBJECT:'\\',"brazier",(08,09)
+OBJECT:'\\',"brazier",(18,15)
+OBJECT:'\\',"brazier",(28,05)
+OBJECT:'\\',"brazier",(28,13)
 # Surround the temple with fire
 TRAP:"fire",(13,05)
@@ -673,2 +737,105 @@
 MONSTER:'V',random,random
 STAIR:(63,15),up
+
+
+#	The "fill" level for Gehennom
+#
+#	This level is used to fill out any levels not occupied by
+#	specific levels as defined above.
+#
+LEVEL: "hellfill"
+FLAGS:mazelevel
+INIT_MAP: mines,'.',' ',true,true,unlit,true,'L'
+TELEPORT_REGION:levregion(11,01,59,19),levregion(01,01,02,02)
+NOMAP
+#
+#  always put stairs relatively far apart
+#
+IF [50%] {
+  IF [50%] {
+    # Option 1: Up Left, Down Right
+    STAIR:levregion(01,01,20,20),levregion(40,10,44,12),up
+    STAIR:levregion(50,01,70,20),levregion(45,10,49,12),down
+  } ELSE {
+    # Option 2: Up Right, Down Left
+    STAIR:levregion(50,01,70,20),levregion(45,10,49,12),up
+    STAIR:levregion(01,01,20,20),levregion(40,10,44,12),down
+  }
+} ELSE {
+  IF [50%] {
+  # Option 3: Up Center, Down Elsewhere
+    STAIR:levregion(30,01,50,20),levregion(38,01,42,20),up
+    STAIR:levregion(01,01,70,20),levregion(30,01,50,20),down
+  } ELSE {
+  # Option 4: Down Center, Up Elsewhere
+    STAIR:levregion(01,01,70,20),levregion(30,01,50,20),up
+    STAIR:levregion(30,01,50,20),levregion(38,01,42,20),down
+  }
+}
+#
+RANDOM_OBJECTS:'(','/','=','+',')','[','?','*','%'
+OBJECT: object[0], random, random
+OBJECT: object[0], random, random
+OBJECT: object[1], random, random
+OBJECT: object[2], random, random
+OBJECT: object[3], random, random
+OBJECT: object[4], random, random
+OBJECT: random, random, random
+OBJECT: random, random, random
+#
+RANDOM_MONSTERS:'V','D',' ','&','Z'
+MONSTER:monster[0],random,random,hostile
+MONSTER:monster[0],random,random,hostile
+MONSTER:monster[1],random,random,hostile
+MONSTER:monster[1],random,random,hostile
+MONSTER:monster[2],random,random,hostile
+MONSTER:monster[3],random,random,hostile
+MONSTER:random,random,random,hostile
+MONSTER:'H',random,random,hostile
+# chance of evil critters
+IF [50%] {
+  MONSTER:'L',random,random,hostile
+} ELSE {
+  MONSTER:random,random,random,hostile
+}
+IF [66%] {
+# could be a snark now, so up the percentage a bit
+  MONSTER:'J',random,random,hostile
+} ELSE {
+  MONSTER:random,random,random,hostile
+}
+# chance of lava spillage, or maybe lava river?
+IF [50%] {
+	IF [60%] {
+	SPILL: random, 'L', north, 20, lit
+	}
+	IF [60%] {
+	SPILL: random, 'L', south, 20, lit
+	}
+	IF [60%] {
+	SPILL: random, 'L', east, 20, lit
+	}
+	IF [60%] {
+	SPILL: random, 'L', west, 20, lit
+	}
+} ELSE {
+	IF [50%] {
+		RANDLINE: (30,00),(50,19), 'L', lit, 10, 2
+	} ELSE {
+		RANDLINE: (50,00),(30,19), 'L', lit, 10, 2
+	}
+}
+
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+TRAP: random, random
+#
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Healer.des nethack/dat/Healer.des
--- nh_orig/dat/Healer.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Healer.des	2009-10-05 13:36:36.541418110 -0400
@@ -9,6 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Hea-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Hea-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"giant rat"), (16,'r'), (16,"snake"), (4,'Y')
 GEOMETRY:center,center
 MAP
@@ -23,5 +25,5 @@
 PPPP..........PPPPP.....|.S.|......-----------|S|.|......PPPPPP.PPP.......PP
 PPPPPP......PPPPPP......|.|.|......|...|......|.|.|.....PPPPPP...PP.......PP
-PPPPPPPPPPPPPPPPPPP.....+.|.|......S.\.S......|.|.+......PPPPPP.PPPP.......P
+PPPPPPPPPPPPPPPPPPP.....+.|.|......S...S......|.|.+......PPPPPP.PPPP.......P
 PPP...PPPPP...PPPP......|.|.|......|...|......|.|.|.......PPPPPPPPPPP.....PP
 PP.....PPP.....PPP......|.|S|-----------......|.S.|......PPPPPPPPPPPPPPPPPPP
@@ -34,4 +36,7 @@
 PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
 ENDMAP
+
+REPLACE_TERRAIN:(01,01,74,18), 'P', '.', lit, 15%
+
 # Dungeon Description
 REGION:(00,00,75,19),lit,"ordinary"
@@ -56,4 +61,5 @@
 DOOR:locked,(50,10)
 # Hippocrates
+OBJECT:'\',"throne",(37,10)
 MONSTER:'@',"Hippocrates",(37,10)
 # The treasure of Hippocrates
@@ -108,8 +114,9 @@
 #
 
-MAZE: "Hea-loca",' '
-FLAGS: hardfloor
+LEVEL: "Hea-loca"
+FLAGS: hardfloor,mazelevel
 #
-INIT_MAP: '.' , 'P', true , true , lit , false
+INIT_MAP: mines, '.' , 'P', true , true , lit , false
+MON_GENERATION:86%, (64,"giant rat"), (16,'r'), (16,"snake"), (4,'Y')
 GEOMETRY:center,center
 MAP
@@ -208,7 +215,9 @@
 #
 
-MAZE: "Hea-goal", 'P'
+LEVEL: "Hea-goal"
+FLAGS:mazelevel
 #
-INIT_MAP: '.' , 'P' , false , true , lit , false
+INIT_MAP: mines, '.' , 'P' , false , true , lit , false
+MON_GENERATION:86%, (64,"giant rat"), (16,'r'), (16,"snake"), (4,'Y')
 GEOMETRY:center,center
 MAP
@@ -233,5 +242,5 @@
 NON_DIGGABLE:(00,00,40,11)
 # Objects
-OBJECT:')',"quarterstaff",(20,06),blessed,0,"The Staff of Aesculapius"
+OBJECT:')',"quarterstaff",(20,06),blessed,0,NAME:"The Staff of Aesculapius"
 OBJECT:'/',"lightning",(20,06)
 OBJECT:random,random,random
@@ -299,6 +308,8 @@
 #
 
-MAZE: "Hea-fila" , 'P'
-INIT_MAP: '.' , 'P' , false , true , lit , false
+LEVEL: "Hea-fila"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'P' , false , true , lit , false
+MON_GENERATION:86%, (64,"giant rat"), (16,'r'), (16,"snake"), (4,'Y')
 NOMAP
 #
@@ -334,6 +345,8 @@
 TRAP: random, random
 
-MAZE: "Hea-filb" , 'P'
-INIT_MAP: '.' , 'P' , false , true , lit , false
+LEVEL: "Hea-filb"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'P' , false , true , lit , false
+MON_GENERATION:86%, (64,"giant rat"), (16,'r'), (16,"snake"), (4,'Y')
 NOMAP
 #
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/help nethack/dat/help
--- nh_orig/dat/help	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/help	2009-09-08 10:31:12.303292627 -0400
@@ -159,4 +159,6 @@
         *       Tell what equipment you are using; combines the preceding five.
         $       Count your gold pieces.
+        %       Set your chosen ranged weapon; this weapon will be auto-wielded
+                when you attempt to 'f'ire a missile.
         +       List the spells you know; also rearrange them if desired.
         \       Show what types of objects have been discovered.
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/hh nethack/dat/hh
--- nh_orig/dat/hh	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/hh	2009-09-08 10:30:53.085295913 -0400
@@ -73,4 +73,5 @@
 *               ask for combination of ),[,=,",( all at once
 $       gold    count your gold
+%       rwield  assign chosen ranged weapon
 +       spells  list the spells you know; also rearrange them if desired
 _       travel  move via a shortest-path algorithm to a point on the map 
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Knight.des nethack/dat/Knight.des
--- nh_orig/dat/Knight.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Knight.des	2009-10-05 13:36:36.545418791 -0400
@@ -9,8 +9,9 @@
 #	and receive your quest assignment.
 #
-MAZE: "Kni-strt",'.'
-FLAGS: noteleport,hardfloor
+LEVEL: "Kni-strt"
+FLAGS: noteleport,hardfloor,mazelevel
 # This is a kludge to init the level as a lit field.
-INIT_MAP: '.' , '.' , false , false , lit , false
+INIT_MAP: mines, '.' , '.' , false , false , lit , false
+MON_GENERATION:86%, (64,"quasit"), (16,'i'), (16,"ochre jelly"), (4,'j')
 GEOMETRY:center,center
 MAP
@@ -22,5 +23,5 @@
 ...|.|-----------------|++|-----------------|.|...
 ...|.|.................|..|.........|.......|.|...
-...|.|...\.............+..+.........|.......|.|...
+...|.|.................+..+.........|.......|.|...
 ...|.|.................+..+.........+.......|.|...
 ...|.|.................|..|.........|.......|.|...
@@ -61,4 +62,5 @@
 DOOR:closed,(45,12)
 # King Arthur
+OBJECT:'\',"throne",(09,07)
 MONSTER:'@',"King Arthur",(09,07)
 # The treasure of King Arthur
@@ -106,7 +108,8 @@
 #
 
-MAZE: "Kni-loca",' '
-FLAGS: hardfloor
-INIT_MAP: '.' , 'P' , false , true , lit , false
+LEVEL: "Kni-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP: mines, '.' , 'P' , false , true , lit , false
+MON_GENERATION:86%, (64,"quasit"), (16,'i'), (16,"ochre jelly"), (4,'j')
 GEOMETRY:center,center
 MAP
@@ -245,5 +248,8 @@
 #
 
-MAZE: "Kni-goal", ' '
+LEVEL: "Kni-goal"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"quasit"), (16,'i'), (16,"ochre jelly"), (4,'j')
 GEOMETRY:center,center
 MAP
@@ -269,4 +275,7 @@
 .......PPPP...                                                              
 ENDMAP
+
+REPLACE_TERRAIN:(00,00,15,19), '.', 'P', lit, 15%
+
 # Dungeon Description
 REGION:(00,00,14,19),lit,"ordinary"
@@ -277,5 +286,5 @@
 NON_DIGGABLE:(00,00,75,19)
 # Objects
-OBJECT:'(',"mirror",(50,06),blessed,0,"The Magic Mirror of Merlin"
+OBJECT:'(',"mirror",(50,06),blessed,0,NAME:"The Magic Mirror of Merlin"
 OBJECT:random,random,(33,01)
 OBJECT:random,random,(33,02)
@@ -347,6 +356,8 @@
 #
 
-MAZE: "Kni-fila" , '.'
-INIT_MAP: '.' , 'P' , false , true , lit , false
+LEVEL: "Kni-fila"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'P' , false , true , lit , false
+MON_GENERATION:86%, (64,"quasit"), (16,'i'), (16,"ochre jelly"), (4,'j')
 NOMAP
 #
@@ -375,6 +386,8 @@
 TRAP: random, random
 
-MAZE: "Kni-filb" , '.'
-INIT_MAP: '.' , 'P' , false , true , lit , false
+LEVEL: "Kni-filb"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'P' , false , true , lit , false
+MON_GENERATION:86%, (64,"quasit"), (16,'i'), (16,"ochre jelly"), (4,'j')
 NOMAP
 #
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/knox.des nethack/dat/knox.des
--- nh_orig/dat/knox.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/knox.des	2009-11-22 06:29:54.205273467 -0500
@@ -4,6 +4,7 @@
 # NetHack may be freely redistributed.  See license for details.
 #
-MAZE:"knox",' '
-FLAGS: noteleport
+LEVEL:"knox"
+FLAGS: noteleport,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -18,5 +19,5 @@
 |     |..........}}}|...............|..........|}}}.................+...|..|
 | -------..........}|...............S..........|}...................|...|..|
-| |.....|..........}|...............|......\...S}...................|...|..|
+| |.....|..........}|...............|..........S}...................|...|..|
 | |.....+........}}}|...............|..........|}}}.................+...|..|
 | |.....|........}---S------------------------S---}.................|...|..|
@@ -34,6 +35,9 @@
 BRANCH:(08,16,08,16),(0,0,0,0)
 #   Throne room, with Croesus on the throne
+OBJECT:'\',"throne",(43,10)
 REGION:(37,08,46,11),lit,"throne"
-MONSTER:'@',"Croesus",(43,10),hostile
+MONSTER:'@',"Croesus",(43,10),hostile {
+  OBJECT:')',"two-handed sword"
+}
 #   The Vault
 #   Using unfilled morgue for
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/medusa.des nethack/dat/medusa.des
--- nh_orig/dat/medusa.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/medusa.des	2009-09-25 15:37:11.639293430 -0400
@@ -7,6 +7,7 @@
 #
 
-MAZE:"medusa-1",' '
-FLAGS: noteleport
+LEVEL:"medusa-1"
+FLAGS: noteleport,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -32,4 +33,7 @@
 }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
 ENDMAP
+
+REPLACE_TERRAIN:(01,01,73,18), '}', '.', lit, 5%
+
 # Dungeon Description
 # (must maintain one room definition; `unfilled' forces its room to be kept)
@@ -54,18 +58,19 @@
 NON_DIGGABLE:(30,06,46,13)
 # Objects
-CONTAINER:'`',"statue",(36,10),uncursed,"knight",3,"Perseus"
-OBJECT[75%]:'[',"shield of reflection",contained,cursed,+0
-OBJECT[25%]:'[',"levitation boots",contained,random,+0
-OBJECT[50%]:')',"scimitar",contained,blessed,+2
-OBJECT[50%]:'(',"sack",contained
+CONTAINER:'`',"statue",(36,10),uncursed,"knight",3,NAME:"Perseus" {
+  OBJECT[25%]:'[',"shield of reflection",cursed,+0
+  OBJECT[75%]:'[',"levitation boots",+0
+  OBJECT[50%]:')',"scimitar",blessed,+2
+  OBJECT[50%]:'(',"sack"
+}
 # These aren't really containers, but specifying CONTAINER forces them to be
 # empty, since CONTAINERs contain only what is explicitly specified.
-CONTAINER:'`',"statue",random
-CONTAINER:'`',"statue",random
-CONTAINER:'`',"statue",random
-CONTAINER:'`',"statue",random
-CONTAINER:'`',"statue",random
-CONTAINER:'`',"statue",random
-CONTAINER:'`',"statue",random
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -107,6 +112,7 @@
 MONSTER:random,random,random
 
-MAZE:"medusa-2",' '
-FLAGS: noteleport
+LEVEL:"medusa-2"
+FLAGS: noteleport,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -132,4 +138,7 @@
 }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
 ENDMAP
+
+REPLACE_TERRAIN:(01,01,73,18), '}', '.', lit, 5%
+
 # Dungeon Description
 REGION:(00,00,74,19),lit,"ordinary"
@@ -152,17 +161,18 @@
 NON_DIGGABLE:(60,02,73,17)
 # Objects
-CONTAINER:'`',"statue",(68,10),uncursed,"knight",3,"Perseus"
-OBJECT[25%]:'[',"shield of reflection",contained,cursed,+0
-OBJECT[75%]:'[',"levitation boots",contained,random,+0
-OBJECT[50%]:')',"scimitar",contained,blessed,+2
-OBJECT[50%]:'(',"sack",contained
-CONTAINER:'`',"statue",(64,08)
-CONTAINER:'`',"statue",(65,08)
-CONTAINER:'`',"statue",(64,09)
-CONTAINER:'`',"statue",(65,09)
-CONTAINER:'`',"statue",(64,10)
-CONTAINER:'`',"statue",(65,10)
-CONTAINER:'`',"statue",(64,11)
-CONTAINER:'`',"statue",(65,11)
+CONTAINER:'`',"statue",(68,10),uncursed,"knight",3,NAME:"Perseus" {
+  OBJECT[25%]:'[',"shield of reflection",cursed,+0
+  OBJECT[75%]:'[',"levitation boots",+0
+  OBJECT[50%]:')',"scimitar",blessed,+2
+  OBJECT[50%]:'(',"sack"
+}
+CONTAINER:'`',"statue",(64,08) { }
+CONTAINER:'`',"statue",(65,08) { }
+CONTAINER:'`',"statue",(64,09) { }
+CONTAINER:'`',"statue",(65,09) { }
+CONTAINER:'`',"statue",(64,10) { }
+CONTAINER:'`',"statue",(65,10) { }
+CONTAINER:'`',"statue",(64,11) { }
+CONTAINER:'`',"statue",(65,11) { }
 OBJECT:'`',"boulder",(04,04)
 OBJECT:'/',random,(52,09)
@@ -214,2 +224,253 @@
 MONSTER:random,random,random
 MONSTER:random,random,random
+
+LEVEL:"medusa-3"
+FLAGS: noteleport,mazelevel
+INIT_MAP:solidfill,' '
+GEOMETRY:center,center
+#
+# Here you disturb ravens nesting in the trees.
+#
+MAP
+}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+}}}}}}}}}}.}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}.}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+}}}}}}}}T..T.}}}}}}}}}}}}}}}}}}}}..}}}}}}}}.}}}...}}}}}}}.}}}}}......}}}}}}}
+}}}}}}.......T.}}}}}}}}}}}..}}}}..T.}}}}}}...T...T..}}...T..}}..-----..}}}}}
+}}}...-----....}}}}}}}}}}.T..}}}}}...}}}}}.....T..}}}}}......T..|...|.T..}}}
+}}}.T.|...|...T.}}}}}}}.T......}}}}..T..}}.}}}.}}...}}}}}.T.....+...|...}}}}
+}}}}..|...|.}}.}}}}}.....}}}T.}}}}.....}}}}}}.T}}}}}}}}}}}}}..T.|...|.}}}}}}
+}}}}}.|...|.}}}}}}..T..}}}}}}}}}}}}}T.}}}}}}}}..}}}}}}}}}}}.....-----.}}}}}}
+}}}}}.--+--..}}}}}}...}}}}}}}}}}}}}}}}}}}T.}}}}}}}}}}}}}}}}.T.}........}}}}}
+}}}}}.......}}}}}}..}}}}}}}}}.}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}.}}}.}}.T.}}}}}}
+}}.T...T...}}}}T}}}}}}}}}}}....}}}}}}}}}}T}}}}}.T}}...}}}}}}}}}}}}}}...}}}}}
+}}}...T}}}}}}}..}}}}}}}}}}}.T...}}}}}}}}.T.}.T.....T....}}}}}}}}}}}}}.}}}}}}
+}}}}}}}}}}}}}}}....}}}}}}}...}}.}}}}}}}}}}............T..}}}}}.T.}}}}}}}}}}}
+}}}}}}}}}}}}}}}}..T..}}}}}}}}}}}}}}..}}}}}..------+--...T.}}}....}}}}}}}}}}}
+}}}}.}..}}}}}}}.T.....}}}}}}}}}}}..T.}}}}.T.|...|...|....}}}}}.}}}}}...}}}}}
+}}}.T.}...}..}}}}T.T.}}}}}}.}}}}}}}....}}...|...+...|.}}}}}}}}}}}}}..T...}}}
+}}}}..}}}.....}}...}}}}}}}...}}}}}}}}}}}}}T.|...|...|}}}}}}}}}}}....T..}}}}}
+}}}}}..}}}.T..}}}.}}}}}}}}.T..}}}}}}}}}}}}}}---S-----}}}}}}}}}}}}}....}}}}}}
+}}}}}}}}}}}..}}}}}}}}}}}}}}}.}}}}}}}}}}}}}}}}}T..T}}}}}}}}}}}}}}}}}}}}}}}}}}
+}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+ENDMAP
+
+REPLACE_TERRAIN:(01,01,73,18), '}', '.', lit, 5%
+
+RANDOM_PLACES:(08,06),(66,05),(46,15)
+REGION:(00,00,74,19),lit,"ordinary"
+REGION:(49,14,51,16),random,"ordinary",unfilled
+REGION:(07,05,09,07),unlit,"ordinary"
+REGION:(65,04,67,06),unlit,"ordinary"
+REGION:(45,14,47,16),unlit,"ordinary"
+# All places are accessible also with jumping, so don't bother
+# restricting the placement when teleporting from levels below this.
+TELEPORT_REGION:(33,02,38,07),(0,0,0,0),down
+STAIR:(32,01,39,07),(0,0,0,0),up
+STAIR:place[0],down
+DOOR:locked,(08,08)
+DOOR:locked,(64,05)
+DOOR:random,(50,13)
+DOOR:locked,(48,15)
+# 
+FOUNTAIN:place[1]
+#
+CONTAINER:'`',"statue",place[2],uncursed,"knight",1,NAME:"Perseus" {
+  OBJECT[75%]:'[',"shield of reflection",cursed,+0
+  OBJECT[25%]:'[',"levitation boots",+0
+  OBJECT[50%]:')',"scimitar",blessed,+2
+  OBJECT[50%]:'(',"sack"
+}
+#
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:'?',"blank paper",(48,18)
+OBJECT:'?',"blank paper",(48,18)
+#
+TRAP:"rust",random
+TRAP:"rust",random
+TRAP:"board",random
+TRAP:"board",random
+TRAP:random,random
+#
+MONSTER:'@',"Medusa",place[0]
+MONSTER:';',"giant eel",random
+MONSTER:';',"giant eel",random
+MONSTER:';',"jellyfish",random
+MONSTER:';',"jellyfish",random
+MONSTER:'n',"wood nymph",random
+MONSTER:'n',"wood nymph",random
+MONSTER:'n',"water nymph",random
+MONSTER:'n',"water nymph",random
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+MONSTER:'B',"raven",random,hostile
+
+
+LEVEL:"medusa-4"
+FLAGS: noteleport,mazelevel
+INIT_MAP:solidfill,' '
+GEOMETRY:center,center
+#
+# Here the Medusa rules some slithery monsters from her 'palace', with
+# a yellow dragon nesting in the backyard.
+#
+MAP
+}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+}}}}}}}}}}}}}}........}}}}}}}}}}}}}}}}}}}}}}}..}}}.....}}}}}}}}}}}----|}}}}}
+}}}}}}..----------F-.....}}}}}}}}}}}}}}}}..---...}}}}....T.}}}}}}}....|}}}}}
+}}}.....|...F......S}}}}....}}}}}}}...}}.....|}}.}}}}}}}......}}}}|......}}}
+}}}.....+...|..{...|}}}}}}}}}}}}.....}}}}|...|}}}}}}}}}}}.}}}}}}}}----.}}}}}
+}}......|...|......|}}}}}}}}}......}}}}}}|.......}}}}}}}}}}}}}..}}}}}...}}}}
+}}|-+--F|-+--....|F|-|}}}}}....}}}....}}}-----}}.....}}}}}}}......}}}}.}}}}}
+}}|...}}|...|....|}}}|}}}}}}}..}}}}}}}}}}}}}}}}}}}}....}}}}}}}}....T.}}}}}}}
+}}|...}}F...+....F}}}}}}}..}}}}}}}}}}}}}}...}}}}}}}}}}}}}}}}}}}}}}....}}..}}
+}}|...}}|...|....|}}}|}....}}}}}}....}}}...}}}}}...}}}}}}}}}}}}}}}}}.....}}}
+}}--+--F|-+--....-F|-|....}}}}}}}}}}.T...}}}}....---}}}}}}}}}}}}}}}}}}}}}}}}
+}}......|...|......|}}}}}.}}}}}}}}}....}}}}}}}.....|}}}}}}}}}.}}}}}}}}}}}}}}
+}}}}....+...|..{...|.}}}}}}}}}}}}}}}}}}}}}}}}}}.|..|}}}}}}}......}}}}...}}}}
+}}}}}}..|...F......|...}}}}}}}}}}..---}}}}}}}}}}--.-}}}}}....}}}}}}....}}}}}
+}}}}}}}}-----S----F|....}}}}}}}}}|...|}}}}}}}}}}}}...}}}}}}...}}}}}}..}}}}}}
+}}}}}}}}}..............T...}}}}}.|.......}}}}}}}}}}}}}}..}...}.}}}}....}}}}}
+}}}}}}}}}}....}}}}...}...}}}}}.......|.}}}}}}}}}}}}}}.......}}}}}}}}}...}}}}
+}}}}}}}}}}..}}}}}}}}}}.}}}}}}}}}}-..--.}}}}}}}}..}}}}}}..T...}}}..}}}}}}}}}}
+}}}}}}}}}...}}}}}}}}}}}}}}}}}}}}}}}...}}}}}}}....}}}}}}}.}}}..}}}...}}}}}}}}
+}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}.}}}}}}....}}}}}}}}}}}}}}}}}}}...}}}}}}
+}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+ENDMAP
+
+REPLACE_TERRAIN:(01,01,73,18), '}', '.', lit, 5%
+
+#
+RANDOM_PLACES:(04,08),(10,04),(10,08),(10,12)
+#
+REGION:(00,00,74,19),lit,"ordinary"
+REGION:(13,03,18,13),lit,"ordinary",unfilled
+#
+TELEPORT_REGION:(64,01,74,17),(0,0,0,0),down
+TELEPORT_REGION:(02,02,18,13),(0,0,0,0),up
+#
+STAIR:(67,01,74,20),(0,0,0,0),up
+STAIR:place[0],down
+# 
+DOOR:locked,(04,06)
+DOOR:locked,(04,10)
+DOOR:locked,(08,04)
+DOOR:locked,(08,12)
+DOOR:locked,(10,06)
+DOOR:locked,(10,10)
+DOOR:locked,(12,08)
+#
+BRANCH:levregion(27,00,79,20),(0,0,0,0)
+#
+NON_DIGGABLE:(01,01,22,14)
+#
+OBJECT:'(',"crystal ball",(07,08)
+#
+CONTAINER:'`',"statue",place[1],uncursed,"knight",1,NAME:"Perseus" {
+  OBJECT[75%]:'[',"shield of reflection",cursed,+0
+  OBJECT[25%]:'[',"levitation boots",+0
+  OBJECT[50%]:')',"scimitar",blessed,+2
+  OBJECT[50%]:'(',"sack"
+}
+#
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+CONTAINER:'`',"statue",random { }
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+OBJECT:random,random,random
+# 
+TRAP:random,random
+TRAP:random,random
+TRAP:random,random
+TRAP:random,random
+TRAP:random,random
+TRAP:random,random
+TRAP:random,random
+#
+MONSTER:'@',"Medusa",place[0]
+MONSTER:';',"kraken",(07,07)
+#
+# the nesting dragon
+MONSTER:'D',"yellow dragon", (05,04), asleep
+MONSTER[50%]:'D',"baby yellow dragon", (04,04), asleep
+MONSTER[25%]:'D',"baby yellow dragon", (04,05), asleep
+OBJECT:'%',"egg", (05,04), "yellow dragon"
+OBJECT[50%]:'%',"egg", (05,04), "yellow dragon"
+OBJECT[25%]:'%',"egg", (05,04), "yellow dragon"
+#
+MONSTER:';',"giant eel",random
+MONSTER:';',"giant eel",random
+MONSTER:';',"jellyfish",random
+MONSTER:';',"jellyfish",random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'S',random,random
+MONSTER:'N',"black naga hatchling", random
+MONSTER:'N',"black naga hatchling", random
+MONSTER:'N',"black naga hatchling", random
+MONSTER:'N',"black naga hatchling", random
+MONSTER:'N',"black naga", random
+MONSTER:'N',"black naga", random
+MONSTER:'N',"black naga", random
+MONSTER:'N',"black naga", random
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/mines.des nethack/dat/mines.des
--- nh_orig/dat/mines.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/mines.des	2009-10-25 09:57:42.339371662 -0400
@@ -10,6 +10,7 @@
 #	specific levels as defined below.
 #
-MAZE: "minefill" , ' '
-INIT_MAP: '.' , ' ' , true , true , random , true
+LEVEL: "minefill"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , ' ' , true , true , random , true
 NOMAP
 #
@@ -46,85 +47,179 @@
 TRAP: random, random
 
-
 # Minetown variant 1
 # "Frontier Town"
 #
+# A tragic accident has occurred to Frontier Town....
+# 
+# Orcish Town - a variant of Frontier Town that has been
+# overrun by orcs.  Note the barricades (iron bars).
+#
 LEVEL: "minetn-1"
+FLAGS:mazelevel
+INIT_MAP:mines,'.',' ',true,true,random,true
+GEOMETRY:center,center
+MAP
+.....................................
+.----------------F------------------.
+.|.................................|.
+.|.-------------......------------.|.
+.|.|...|...|...|......|..|...|...|.|.
+.F.|...|...|...|......|..|...|...|.|.
+.|.|...|...|...|......|..|...|...|.F.
+.|.|...|...|----......------------.|.
+.|.---------.......................|.
+.|.................................|.
+.|.---------.....--...--...........|.
+.|.|...|...|----.|.....|.---------.|.
+.|.|...|...|...|.|.....|.|..|....|.|.
+.|.|...|...|...|.|.....|.|..|....|.|.
+.|.|...|...|...|.|.....|.|..|....|.|.
+.|.-------------.-------.---------.|.
+.|.................................F.
+.-----------F------------F----------.
+.....................................
+ENDMAP
 
-ROOM: "ordinary" , lit, (3,3), (center,center), (31,15)
-NAME: "town"
-FOUNTAIN: (13, 7)
-FOUNTAIN: (20, 7)
-
-# The Town Watch
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watch captain", random, peaceful
-
-SUBROOM: "shop" , lit, (2,2), (3,4), "town"
-CHANCE: 90
-DOOR: false, closed, south, random
-
-SUBROOM: "tool shop", lit, (2,9), (3,4), "town"
-CHANCE: 90
-DOOR: false, closed, north, random
-
-SUBROOM: "ordinary", unlit, (6,2), (3,4), "town"
-DOOR: false, closed, south, random
-
-SUBROOM: "ordinary", lit, (6,9), (3,4), "town"
-DOOR: false, closed, north, random
-
-SUBROOM: "food shop", lit, (10,2), (2,3), "town"
-CHANCE: 90
-DOOR: false, closed, south, random
-
-SUBROOM: "candle shop", lit, (22,2), (3,3), "town"
-DOOR: false, closed, south, random
-
-SUBROOM: "ordinary", unlit, (10,10), (2,3), "town"
-DOOR: false, locked, east, random
-MONSTER: 'G', "gnome", random
+# Don't let the player fall into his likely death
+TELEPORT_REGION:levregion(01,01,20,19),levregion(20,00,70,19)
+REGION:(00,00,36,16),lit,"ordinary"
+STAIR:levregion(01,03,20,19),(00,00,36,15),up
+STAIR:levregion(61,03,75,19),(00,00,36,15),down
 
-SUBROOM: "ordinary", lit, (19,2),  (2,3), "town"
-DOOR: false, locked, west, random
-MONSTER: 'G', "gnome", random
+# shame we can't make polluted fountains
+FOUNTAIN:(16,09)
+FOUNTAIN:(25,09)
 
-SUBROOM: "temple", lit, (15,9), (4,4), "town"
-DOOR: false, closed, north, random
-ALTAR:(02,02),align[0],shrine
-MONSTER: 'G', "gnomish wizard", random
-MONSTER: 'G', "gnomish wizard", random
+# the altar's defiled; useful for BUC but never coaligned
+ALTAR:(20,13),noalign,shrine
 
-SUBROOM: "ordinary", lit, (22,10), (2,3), "town"
-DOOR: false, locked, west, random
+# set up the shop doors; could be broken down
+DOOR:random,(5,8)
+DOOR:random,(9,8)
+DOOR:random,(13,7)
+DOOR:random,(22,5)
+DOOR:random,(27,7)
+DOOR:random,(31,7)
+DOOR:random,(5,10)
+DOOR:random,(9,10)
+DOOR:random,(15,13)
+DOOR:random,(25,13)
+DOOR:random,(31,11)
 
-SUBROOM: "ordinary", lit, (26,2), (3,3), "town"
-DOOR: false, closed, south, random
-MONSTER: 'G', "gnome lord", random
+# knock a few holes in the shop interior walls
+REPLACE_TERRAIN:(07,04,11,06),'|','.',lit,18%
+REPLACE_TERRAIN:(25,04,29,06),'|','.',lit,18%
+REPLACE_TERRAIN:(07,12,11,14),'|','.',lit,18%
+REPLACE_TERRAIN:(28,12,28,14),'|','.',lit,33%
 
-SUBROOM: "ordinary", unlit, (25,10), (4,3), "town"
-DOOR: false, closed, north, random
+# One spot each in most shops...
+RANDOM_PLACES:(05,04),(09,05),(13,04),(26,04),(31,05),(30,14),(05,14),(10,13),(26,14),(27,13)
 
-ROOM: "ordinary" , random, random, random, random
-STAIR: random, up
+# scatter some bodies
+OBJECT:'%',"corpse",(20,12),"aligned priest",0
+OBJECT:'%',"corpse",place[0],"shopkeeper",0
+OBJECT:'%',"corpse",place[1],"shopkeeper",0
+OBJECT:'%',"corpse",place[2],"shopkeeper",0
+OBJECT:'%',"corpse",place[3],"shopkeeper",0
+OBJECT:'%',"corpse",place[4],"shopkeeper",0
+OBJECT:'%',"corpse",random,"watchman",0
+OBJECT:'%',"corpse",random,"watchman",0
+OBJECT:'%',"corpse",random,"watchman",0
+OBJECT:'%',"corpse",random,"watchman",0
+OBJECT:'%',"corpse",random,"watch captain",0
 
-ROOM: "ordinary" , random, random, random, random
-STAIR: random, down
-TRAP: random, random
-MONSTER: 'G', "gnome", random
-MONSTER: 'G', "gnome", random
+# Rubble!
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'`',"boulder",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
+OBJECT:'*',"rock",random
 
-ROOM: "ordinary" , random, random, random, random
-MONSTER: 'h', "dwarf", random
+# Guarantee 7 candles since we won't have Izchak available
+OBJECT:'(',"wax candle",place[0],quantity:2
+OBJECT:'(',"wax candle",place[1],quantity:1
+OBJECT:'(',"wax candle",place[2],quantity:2
+OBJECT:'(',"tallow candle",place[3],quantity:3
+OBJECT:'(',"tallow candle",place[2],quantity:1
+OBJECT:'(',"tallow candle",place[0],quantity:1
 
-ROOM: "ordinary" , random, random, random, random
-TRAP: random, random
-MONSTER: 'G', "gnome", random
+# go ahead and leave a lamp next to one corpse to be suggestive
+# and some empty wands...
+OBJECT:'(',"oil lamp",place[2]
+OBJECT:'/',"striking",place[1],uncursed,0
+OBJECT:'/',"striking",place[3],uncursed,0
+OBJECT:'/',"striking",place[4],uncursed,0
+OBJECT:'/',"magic missile",place[4],uncursed,0
+OBJECT:'/',"magic missile",place[0],uncursed,0
 
-RANDOM_CORRIDORS
+# the Orcish Army
+#
+# We need to specify locations inside the walls
+# for all of these critters since 'random' could
+# put them in our empty 'corridor' around the town
+MONSTER: 'o', "orc-captain", (07,09), hostile
+MONSTER: 'o', "orc-captain", (19,09), hostile
+MONSTER: 'o', "orc-captain", (30,09), hostile
+MONSTER: 'o', "Uruk-hai", (18,04), hostile
+MONSTER: 'o', "Uruk-hai", (19,04), hostile
+MONSTER: 'o', "Uruk-hai", (20,05), hostile
+MONSTER: 'o', "Uruk-hai", (14,09), hostile
+MONSTER: 'o', "Uruk-hai", (25,09), hostile
+MONSTER: 'o', "Mordor orc", (20,04), hostile
+MONSTER: 'o', "Mordor orc", (18,05), hostile
+MONSTER: 'o', "Mordor orc", (19,05), hostile
+MONSTER: 'o', "Mordor orc", (07,02), hostile
+MONSTER: 'o', "Mordor orc", (29,02), hostile
+MONSTER: 'o', "Mordor orc", (07,16), hostile
+MONSTER: 'o', "Mordor orc", (29,16), hostile
+# shamans can be hanging out in/near the temple
+MONSTER: 'o', "orc shaman", (19,11), hostile
+MONSTER: 'o', "orc shaman", (21,11), hostile
+MONSTER: 'o', "orc shaman", (16,12), hostile
+MONSTER: 'o', "orc shaman", (24,12), hostile
+# these are not such a big deal
+# to run into outside the bars
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "hill orc", random, hostile
+MONSTER: 'o', "goblin", random, hostile
+MONSTER: 'o', "goblin", random, hostile
+MONSTER: 'o', "goblin", random, hostile
+MONSTER: 'o', "goblin", random, hostile
+MONSTER: 'o', "goblin", random, hostile
+MONSTER: 'o', "goblin", random, hostile
+MONSTER: 'o', "goblin", random, hostile
+MONSTER: 'o', "goblin", random, hostile
 
+WALLIFY:levregion(1,0, 70,20)
 
 # Minetown variant 2
@@ -133,91 +228,157 @@
 LEVEL: "minetn-2"
 ROOM: "ordinary" , lit, (3,3), (center,center), (31,15)
-NAME: "town"
-FOUNTAIN: (17, 5)
-FOUNTAIN: (13, 8)
-
-# The Town Watch
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watch captain", random, peaceful
+{
 
-SUBROOM: "ordinary", random, (2,0), (2,2), "town"
-DOOR: false, closed, west, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (2,0), (2,2)
+  {
+    ROOMDOOR: false, closed, west|south, random
+  }
+}
 
-SUBROOM: "ordinary", unlit, (5,0), (2,2), "town"
-DOOR: false, closed, south, random
+IF [75%] {
+  SUBROOM: "ordinary", unlit, (5,0), (2,2)
+  {
+    ROOMDOOR: false, closed, west|south, random
+  }
+}
 
-SUBROOM: "ordinary", random, (8,0), (2,2), "town"
-DOOR: false, closed, east, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (8,0), (2,2)
+  {
+    ROOMDOOR: false, closed, east|south, random
+  }
+}
 
-SUBROOM: "ordinary", lit, (16,0), (2,2), "town"
-DOOR: false, closed, west, random
+IF [75%] {
+  SUBROOM: "ordinary", lit, (16,0), (2,2)
+  {
+    ROOMDOOR: false, closed, west|south, random
+  }
+}
 
-SUBROOM: "ordinary", unlit, (19,0), (2,2), "town"
-DOOR: false, closed, south, random
+IF [75%] {
+  SUBROOM: "ordinary", unlit, (19,0), (2,2)
+  {
+    ROOMDOOR: false, closed, west|south, random
+  }
+}
 
-SUBROOM: "ordinary", random, (22,0), (2,2), "town"
-DOOR: false, locked, south, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (22,0), (2,2)
+  {
+    ROOMDOOR: false, locked, west|south, random
 MONSTER: 'G', "gnome", random
+  }
+}
 
-SUBROOM: "ordinary", unlit, (25,0), (2,2), "town"
-DOOR: false, closed, east, random
-
-SUBROOM: "ordinary", lit, (2,5), (2,2), "town"
-DOOR: false, closed, north, random
+IF [75%] {
+  SUBROOM: "ordinary", unlit, (25,0), (2,2)
+  {
+    ROOMDOOR: false, closed, east|south|west, random
+  }
+}
 
-SUBROOM: "ordinary", lit, (5,5), (2,2), "town"
-DOOR: false, closed, south, random
+IF [75%] {
+  SUBROOM: "ordinary", lit, (2,5), (2,2)
+  {
+    ROOMDOOR: false, closed, north|south|west, random
+  }
+}
 
-SUBROOM: "ordinary", random, (8,5), (2,2), "town"
-DOOR: false, locked, north, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (8,5), (2,2)
+  {
+    ROOMDOOR: false, locked, north|south|east, random
 MONSTER: 'G', "gnome", random
+  }
+}
 
-SUBROOM: "shop" , lit, (2,10), (4,3), "town"
-CHANCE: 90
-DOOR: false, closed, west, random
+IF [75%] {
+  SUBROOM: "ordinary", lit, (5,5), (2,2)
+  {
+    ROOMDOOR: false, closed, north|south|east|west, random
+  }
+}
 
-SUBROOM: "tool shop", lit, (23,10), (4,3), "town"
-CHANCE: 90
-DOOR: false, closed, east, random
+SUBROOM: "shop" [90%] , lit, (2,10), (4,3)
+{
+ROOMDOOR: false, closed, north|south|west, random
+}
 
-SUBROOM: "food shop", lit, (24,5), (3,4), "town"
-CHANCE: 90
-DOOR: false, closed, north, random
+SUBROOM: "tool shop" [90%], lit, (23,10), (4,3)
+{
+ROOMDOOR: false, closed, south|east, random
+}
 
-SUBROOM: "candle shop", lit, (11,10), (4,3), "town"
-DOOR: false, closed, east, random
+SUBROOM: "food shop" [90%], lit, (24,5), (3,4)
+{
+ROOMDOOR: false, closed, north|east, random
+}
 
-SUBROOM: "ordinary", unlit, (7,10), (3,3), "town"
-DOOR: false, locked, north, random
+SUBROOM: "candle shop", lit, (11,10), (4,3)
+{
+ROOMDOOR: false, closed, north|south|east, random
+}
+
+IF [75%] {
+  SUBROOM: "ordinary", unlit, (7,10), (3,3)
+  {
+    ROOMDOOR: false, locked, north|south, random
 MONSTER: 'G', "gnome", random
+  }
+}
 
-SUBROOM: "temple", lit, (19,5), (4,4), "town"
-DOOR: false, closed, north, random
+SUBROOM: "temple", lit, (19,5), (4,4)
+{
+ROOMDOOR: false, closed, north|west, random
 ALTAR:(02,02),align[0],shrine
 MONSTER: 'G', "gnomish wizard", random
 MONSTER: 'G', "gnomish wizard", random
+}
 
-SUBROOM: "ordinary", lit, (18,10), (4,3), "town"
-DOOR: false, locked, west, random
+IF [75%] {
+  SUBROOM: "ordinary", lit, (18,10), (4,3)
+  {
+    ROOMDOOR: false, locked, south|west, random
 MONSTER: 'G', "gnome lord", random
+  }
+}
+
+FOUNTAIN: (17, 5)
+FOUNTAIN: (13, 8)
+
+# The Town Watch
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watch captain", random, peaceful
+
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 TRAP: random, random
 MONSTER: 'G', "gnome", random
 MONSTER: 'G', "gnome", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 MONSTER: 'h', "dwarf", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 TRAP: random, random
 MONSTER: 'G', "gnome", random
+}
 
 RANDOM_CORRIDORS
@@ -229,86 +390,143 @@
 LEVEL: "minetn-3"
 ROOM: "ordinary",lit,(3,3),(center,center),(31,15)
-NAME: "town"
-FOUNTAIN:(01,06)
-FOUNTAIN:(29,13)
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watch captain", random, peaceful
+{
 
-SUBROOM:"ordinary",random,(2,2),(2,2),"town"
-DOOR: false,closed,south,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(2,2),(2,2)
+  {
+    ROOMDOOR: false,closed,north|south|west,random
+  }
+}
 
-SUBROOM:"tool shop",lit,(5,3),(2,3),"town"
-CHANCE: 30
-DOOR: false,closed,south,random
+SUBROOM:"tool shop" [30%],lit,(5,3),(2,3)
+{
+ROOMDOOR: false,closed,north|south|east,random
+}
 
-SUBROOM:"ordinary",random,(2,10),(2,3),"town"
-DOOR: false, locked, north, random
+IF [75%] {
+  SUBROOM:"ordinary",random,(2,10),(2,3)
+  {
+    ROOMDOOR: false, locked, north|south|west, random
 MONSTER: 'G',random,random
+  }
+}
 
-SUBROOM:"ordinary",random,(5,9),(2,2),"town"
-DOOR: false,closed,north,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(5,9),(2,2)
+  {
+    ROOMDOOR: false,closed,north|south|east,random
+  }
+}
 
-SUBROOM:"temple",lit,(10,2),(3,4),"town"
-DOOR: false,closed,east,random
+SUBROOM:"temple",lit,(10,2),(3,4)
+{
+ROOMDOOR: false,closed,north|west|east,random
 ALTAR:(1,1),align[0],shrine
 MONSTER: 'G', "gnomish wizard", random
 MONSTER: 'G', "gnomish wizard", random
+}
 
-SUBROOM:"ordinary",random,(11,7),(2,2),"town"
-DOOR: false,closed,west,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(11,7),(2,2)
+  {
+    ROOMDOOR: false,closed,west,random
+  }
+}
 
-SUBROOM:"shop",lit,(10,10),(3,3),"town"
-DOOR:false,closed,west,random
+SUBROOM:"shop",lit,(10,10),(3,3)
+{
+ROOMDOOR:false,closed,west|south,random
+}
 
-SUBROOM:"ordinary",random,(14,8),(2,2),"town"
-DOOR:false,locked,north,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(14,8),(2,2)
+  {
+    ROOMDOOR:false,locked,north,random
 MONSTER: 'G',random,random
+  }
+}
 
-SUBROOM:"ordinary",random,(14,11),(2,2),"town"
-DOOR:false,closed,south,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(14,11),(2,2)
+  {
+    ROOMDOOR:false,closed,north|south,random
+  }
+}
 
-SUBROOM:"tool shop",lit,(17,10),(3,3),"town"
-CHANCE:40
-DOOR:false,closed,north,random
+SUBROOM:"tool shop" [40%],lit,(17,10),(3,3)
+{
+ROOMDOOR:false,closed,north|south,random
+}
 
-SUBROOM:"ordinary",random,(21,11),(2,2),"town"
-DOOR:false,locked,east,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(21,11),(2,2)
+  {
+    ROOMDOOR:false,locked,north|south|east,random
 MONSTER:'G',random,random
+  }
+}
 
-SUBROOM:"food shop",lit,(26,8),(3,2),"town"
-CHANCE:90
-DOOR:false,closed,west,random
+SUBROOM:"food shop" [90%],lit,(26,8),(3,2)
+{
+ROOMDOOR:false,closed,north|south|east|west,random
+}
 
-SUBROOM:"ordinary",random,(16,2),(2,2),"town"
-DOOR:false,closed,west,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(16,2),(2,2)
+  {
+    ROOMDOOR:false,closed,north|south|west,random
+  }
+}
 
-SUBROOM:"ordinary",random,(19,2),(2,2),"town"
-DOOR:false,closed,north,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(19,2),(2,2)
+  {
+    ROOMDOOR:false,closed,north|east|west,random
+  }
+}
 
-SUBROOM:"wand shop",lit,(19,5),(3,2),"town"
-CHANCE:30
-DOOR:false,closed,west,random
+SUBROOM:"wand shop" [30%],lit,(19,5),(3,2)
+{
+ROOMDOOR:false,closed,south|east|west,random
+}
 
-SUBROOM: "candle shop",lit,(25,2),(3,3),"town"
-DOOR:false,closed,south,random
+SUBROOM: "candle shop",lit,(25,2),(3,3)
+{
+ROOMDOOR:false,closed,north|south|east|west,random
+}
+
+FOUNTAIN:(01,06)
+FOUNTAIN:(29,13)
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watch captain", random, peaceful
+
+}
 
 ROOM: "ordinary", random, random, random, random
+{
 STAIR: random, up
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 TRAP: random, random
 MONSTER: 'G', "gnome", random
 MONSTER: 'G', "gnome", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 MONSTER: 'h', "dwarf", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 TRAP: random, random
 MONSTER: 'G', "gnome", random
+}
 
 RANDOM_CORRIDORS
@@ -320,77 +538,121 @@
 LEVEL: "minetn-4"
 ROOM: "ordinary",lit,(3,3),(center,center),(30,15)
-NAME: "town"
-FOUNTAIN:(08,07)
-FOUNTAIN:(18,07)
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watch captain", random, peaceful
+{
 
-SUBROOM:"book shop",lit,(4,2),(3,3),"town"
-DOOR: false,closed,south,random
+SUBROOM:"book shop",lit,(4,2),(3,3)
+{
+ROOMDOOR: false,closed,north|south|west,random
+}
 
-SUBROOM:"ordinary",random,(8,2),(2,2),"town"
-DOOR: false,closed,south,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(8,2),(2,2)
+  {
+    ROOMDOOR: false,closed,north|south,random
+  }
+}
 
-SUBROOM:"temple",lit,(11,3),(5,4),"town"
-DOOR: false,closed,south,random
+SUBROOM:"temple",lit,(11,3),(5,4)
+{
+ROOMDOOR: false,closed,north|south|east,random
 ALTAR:(2,1),align[0],shrine
 MONSTER: 'G', "gnomish wizard", random
 MONSTER: 'G', "gnomish wizard", random
+}
 
-SUBROOM:"ordinary",random,(19,2),(2,2),"town"
-DOOR: false,closed,south,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(19,2),(2,2)
+  {
+    ROOMDOOR: false,closed,north|south|west,random
 MONSTER: 'G', random, random
+  }
+}
 
-SUBROOM:"candle shop",lit,(22,2),(3,3),"town"
-DOOR:false,closed,south,random
+SUBROOM:"candle shop",lit,(22,2),(3,3)
+{
+ROOMDOOR:false,closed,north|south,random
+}
 
-SUBROOM:"ordinary",random,(26,2),(2,2),"town"
-DOOR:false,locked,east,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(26,2),(2,2)
+  {
+    ROOMDOOR:false,locked,north|south|east,random
 MONSTER: 'G',random,random
+  }
+}
 
-SUBROOM:"tool shop",lit,(4,10),(3,3),"town"
-CHANCE:90
-DOOR:false,closed,north,random
+SUBROOM:"tool shop" [90%],lit,(4,10),(3,3)
+{
+ROOMDOOR:false,closed,north|south|west,random
+}
 
-SUBROOM:"ordinary",random,(8,11),(2,2),"town"
-DOOR:false,locked,south,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(8,11),(2,2)
+  {
+    ROOMDOOR:false,locked,north|south,random
 MONSTER: 'k',"kobold shaman",random
 MONSTER: 'k',"kobold shaman",random
 MONSTER: 'f',"kitten",random
 MONSTER: 'f',random,random
+  }
+}
 
-SUBROOM:"food shop",lit,(11,11),(3,2),"town"
-CHANCE:90
-DOOR:false,closed,east,random
+SUBROOM:"food shop" [90%],lit,(11,11),(3,2)
+{
+ROOMDOOR:false,closed,north|south|east,random
+}
 
-SUBROOM:"ordinary",random,(17,11),(2,2),"town"
-DOOR:false,closed,west,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(17,11),(2,2)
+  {
+    ROOMDOOR:false,closed,north|south|west,random
+  }
+}
 
-SUBROOM:"ordinary",random,(20,10),(2,2),"town"
-DOOR:false,locked,north,random
+IF [75%] {
+  SUBROOM:"ordinary",random,(20,10),(2,2)
+  {
+    ROOMDOOR:false,locked,north|south,random
 MONSTER:'G',random,random
+  }
+}
 
-SUBROOM:"shop",lit,(23,10),(3,3),"town"
-CHANCE:90
-DOOR:false,closed,north,random
+SUBROOM:"shop" [90%],lit,(23,10),(3,3)
+{
+ROOMDOOR:false,closed,north|south|east,random
+}
+
+FOUNTAIN:(08,07)
+FOUNTAIN:(18,07)
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watch captain", random, peaceful
+
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 TRAP: random, random
 MONSTER: 'G', "gnome", random
 MONSTER: 'G', "gnome", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 MONSTER: 'h', "dwarf", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 TRAP: random, random
 MONSTER: 'G', "gnome", random
+}
 
 RANDOM_CORRIDORS
@@ -399,5 +661,7 @@
 # "Grotto Town" by Kelly Bailey
 #
-MAZE: "minetn-5",' '
+LEVEL: "minetn-5"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 MAP
@@ -425,4 +689,34 @@
 ENDMAP
 
+IF [75%] {
+   IF [50%] {
+      TERRAIN:(25,8),vertical,2, '|', unlit
+   } ELSE {
+      TERRAIN:(16,13),horizontal,2, '-', unlit
+   }
+}
+
+IF [75%] {
+   IF [50%] {
+      TERRAIN:(36,10),vertical,2, '|', unlit
+   } ELSE {
+      TERRAIN:(32,15),horizontal,2, '-', unlit
+   }
+}
+
+IF [50%] {
+   TERRAIN:(21,4, 22,5),filled, '.',unlit
+   TERRAIN:(14,9),vertical,2, '|', unlit
+}
+
+IF [50%] {
+   TERRAIN:(46,13), '|',unlit
+   TERRAIN:(43,5), horizontal, 5, '-',unlit
+   TERRAIN:(42,6), horizontal, 6, '.',unlit
+   TERRAIN:(47,7), '.', lit
+}
+
+TERRAIN[50%]:(69,11, 71,11), filled, '-',unlit
+
 STAIR:(01,01),up
 STAIR:(46,03),down
@@ -431,12 +725,12 @@
 FOUNTAIN:(66,18)
 
+OBJECT:'\\',"brazier",(08,15)
+OBJECT:'\\',"brazier",(12,15)
+OBJECT:'\\',"brazier",(51,09)
+OBJECT:'\\',"brazier",(65,18)
+OBJECT:'\\',"brazier",(36,15)
+OBJECT:'\\',"brazier",(40,15)
+
 REGION:(00,00,74,20),unlit,"ordinary"
-REGION:(09,13,11,17),lit,"ordinary"
-REGION:(08,14,12,16),lit,"ordinary"
-REGION:(49,07,51,11),lit,"ordinary"
-REGION:(48,08,52,10),lit,"ordinary"
-REGION:(64,17,68,19),lit,"ordinary"
-REGION:(37,13,39,17),lit,"ordinary"
-REGION:(36,14,40,17),lit,"ordinary"
 REGION:(59,02,72,10),lit,"ordinary"
 
@@ -501,24 +795,27 @@
 
 
-# "Bustling Town" by Kelly Bailey
+# Screw Bustling Town.  Let's make a zoo.  --DSR
 #
-MAZE: "minetn-6",' '
-INIT_MAP:'.','-',true,true,lit,true
+LEVEL: "minetn-6"
+FLAGS:mazelevel
+INIT_MAP:mines,'.','-',true,true,lit,true
 GEOMETRY:center,top
+#         1         2         3         4         5         6         7
+#1234567890123456789012345678901234567890123456789012345678901234567890
 MAP
-.-----................----------------.-
-.|...|................|...|..|...|...|..
-.|...+..--+--.........|...|..|...|...|..
-.|...|..|...|..-----..|...|..|-+---+--..
-.-----..|...|--|...|..--+---+-.........|
-........|...|..|...+.............-----..
-........-----..|...|......--+-...|...|..
-.----...|...|+------..{...|..|...+...|..
+.-----...................-------------.-
+.|...|...................|...|...|...|..
+.|...+..--+--...-FFF+F...|...|...|...|..
+.|...|..|...|...|....F...|...|-+---+--..
+.-----..|...|...|....F...---+-.........|
+........|...|...|....F...........-----..
+........-----...------....--+-...|...|..
+.----...|...|.{........{..|..|...+...|..
 .|..+...|...|.............|..|...|...|..
-.|..|...|...|-+-.....---+-------------.|
-.----...--+--..|..-+-|..................
+.|..|...|...|---.....---+-------------.|
+.----...--+--..|..---|..................
 ...|........|..|..|..|----....---------.
-...|..T.....----..|..|...+....|......|-.
-...|-....{........|..|...|....+......|-.
+...|..T.....-+--..+..|...+....|......|-.
+...|-....T........|..|...|....+......|-.
 ...--..-....T.....--------....|......|-.
 .......--.....................----------
@@ -528,10 +825,11 @@
 STAIR:levregion(01,03,20,19),(0,0,39,15),up
 STAIR:levregion(61,03,75,19),(0,0,39,15),down
-FOUNTAIN:(22,07)
-FOUNTAIN:(09,13)
-REGION:(13,5,14,6),unlit,"ordinary"
+FOUNTAIN:(23,07)
+FOUNTAIN:(14,07)
+# protect the zoo against dwarves and inquisitive players
+NON_DIGGABLE:(13,0,24,8)
 REGION:(9,7,11,9),lit,"candle shop"
-REGION:(16,4,18,6),lit,"tool shop"
-REGION:(23,1,25,3),lit,"shop"
+REGION:(9,3,11,5),lit,"tool shop"
+REGION:(26,1,28,3),lit,"shop"
 REGION:(22,12,24,13),lit,"food shop"
 REGION:(31,12,36,14),lit,"temple"
@@ -542,8 +840,6 @@
 DOOR:closed,(10,2)
 DOOR:closed,(10,10)
-DOOR:locked,(13,7)
-DOOR:locked,(14,9)
-DOOR:closed,(19,5)
-DOOR:closed,(19,10)
+DOOR:locked,(13,12)
+DOOR:locked,(20,2)
 DOOR:closed,(24,4)
 DOOR:closed,(24,9)
@@ -567,13 +863,25 @@
 MONSTER: 'G', "gnome lord", random
 MONSTER: 'G', "gnome lord", random
+MONSTER: 'G', "gnomish wizard", random
+MONSTER: 'G', "gnomish wizard", random
 MONSTER: 'h', "dwarf", random
-MONSTER: 'h', "dwarf", random
-MONSTER: 'h', "dwarf", random
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watch captain", random, peaceful
-MONSTER: '@', "watch captain", random, peaceful
-
+# make sure none of these appear inside the zoo, especially the watch captains
+MONSTER: '@', "watchman", (18,8), peaceful
+MONSTER: '@', "watchman", (7,3), peaceful
+MONSTER: '@', "watchman", (31,6), peaceful
+MONSTER: '@', "watch captain", (28,12), peaceful
+MONSTER: '@', "watch captain", (8,12), peaceful
+# The zoo needs some stuff...
+MONSTER: 'f', "tiger", (17,3), hostile
+MONSTER: 'f', "panther", (20,5), hostile
+MONSTER: 'f', "jaguar", (17,4), hostile
+MONSTER: 'q', "mastodon", (20,4), hostile
+# and a couple token handlers
+MONSTER: 'o', "Mordor orc", (17,5), hostile
+MONSTER: 'o', "Mordor orc", (20,3), hostile
+# and a couple shiny prizes as temptation (for the handlers to use, possibly?)
+OBJECT: '/', random, (18,4)
+OBJECT: '/', random, (19,4)
+OBJECT: '=', random, (17,4)
 
 # "Bazaar Town" by Kelly Bailey
@@ -581,113 +889,180 @@
 LEVEL: "minetn-7"
 ROOM: "ordinary" , lit, (3,3), (center,center), (30,15)
-NAME: "town"
-FOUNTAIN: (12, 07)
-FOUNTAIN: (11, 13)
-
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watchman", random, peaceful
-MONSTER: '@', "watch captain", random, peaceful
-MONSTER:'G',"gnome",random
-MONSTER:'G',"gnome",random
-MONSTER:'G',"gnome",random
-MONSTER:'G',"gnome lord",random
-MONSTER:'Y',"monkey",random
-MONSTER:'Y',"monkey",random
+{
 
-SUBROOM: "ordinary", random, (2,2), (4,2), "town"
-DOOR: false, closed, south, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (2,2), (4,2)
+  {
+    ROOMDOOR: false, closed, north|south|west, random
+  }
+}
 
-SUBROOM: "ordinary", random, (7,2), (2,2), "town"
-DOOR: false, closed, north, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (7,2), (2,2)
+  {
+    ROOMDOOR: false, closed, north|west, random
+  }
+}
 
-SUBROOM: "ordinary", random, (7,5), (2,2), "town"
-DOOR: false, closed, south, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (7,5), (2,2)
+  {
+    ROOMDOOR: false, closed, south|west, random
+  }
+}
 
-SUBROOM: "ordinary", lit, (10,2), (3,4), "town"
+IF [75%] {
+  SUBROOM: "ordinary", lit, (10,2), (3,4)
+  {
 MONSTER:'G',"gnome",random
 MONSTER:'Y',"monkey",random
 MONSTER:'Y',"monkey",random
 MONSTER:'Y',"monkey",random
-DOOR: false, closed, south, random
+    ROOMDOOR: false, closed, north|south, random
+  }
+}
 
-SUBROOM: "ordinary", random, (14,2), (4,2), "town"
-DOOR: false, closed, south, 0
+IF [75%] {
+  SUBROOM: "ordinary", random, (14,2), (4,2)
+  {
+    ROOMDOOR: false, closed, south, 0
 MONSTER: 'n', random, random
+  }
+}
 
-SUBROOM: "ordinary", random, (16,5), (2,2), "town"
-DOOR: false, closed, south, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (16,5), (2,2)
+  {
+    ROOMDOOR: false, closed, south|west, random
+  }
+}
 
-SUBROOM: "ordinary", unlit, (19,2), (2,2), "town"
-DOOR: false, locked, east, random
+IF [75%] {
+  SUBROOM: "ordinary", unlit, (19,2), (2,2)
+  {
+    ROOMDOOR: false, locked, north|west|east, random
 MONSTER: 'G',"gnome king",random
+  }
+}
 
-SUBROOM: "food shop", lit, (19,5), (2,3), "town"
-CHANCE: 50
-DOOR: false, closed, south, random
+SUBROOM: "food shop" [50%], lit, (19,5), (2,3)
+{
+ROOMDOOR: false, closed, south|east, random
+}
 
-SUBROOM: "ordinary", random, (2,7), (2,2), "town"
-DOOR: false, closed, east, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (2,7), (2,2)
+  {
+    ROOMDOOR: false, closed, north|west|east, random
+  }
+}
 
-SUBROOM: "tool shop", lit, (2,10), (2,3), "town"
-CHANCE: 50
-DOOR: false, closed, south, random
+SUBROOM: "tool shop" [50%], lit, (2,10), (2,3)
+{
+ROOMDOOR: false, closed, south|west, random
+}
 
-SUBROOM: "candle shop", lit, (5,10),(3,3), "town"
-DOOR: false, closed, north, random
+SUBROOM: "candle shop", lit, (5,10),(3,3)
+{
+ROOMDOOR: false, closed, north|south|east, random
+}
 
-SUBROOM: "ordinary", random, (11,10), (2,2), "town"
-DOOR: false, locked, west, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (11,10), (2,2)
+  {
+    ROOMDOOR: false, locked, north|south|west, random
 MONSTER: 'G',random,random
+  }
+}
 
-SUBROOM: "shop", lit, (14,10), (2,3), "town"
-CHANCE: 60
-DOOR: false, closed, north, random
+SUBROOM: "shop" [60%], lit, (14,10), (2,3)
+{
+ROOMDOOR: false, closed, north|south, random
+}
 
-SUBROOM: "ordinary", random, (17,11), (4,2), "town"
-DOOR: false, closed, north, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (17,11), (4,2)
+  {
+    ROOMDOOR: false, closed, north|south, random
+  }
+}
 
-SUBROOM: "ordinary", random, (22,11), (2,2), "town"
-DOOR: false, closed, south, random
+IF [75%] {
+  SUBROOM: "ordinary", random, (22,11), (2,2)
+  {
+    ROOMDOOR: false, closed, north|south|west, random
 SINK: (00,00)
+  }
+}
 
-SUBROOM: "food shop", lit, (25,11), (3,2), "town"
-CHANCE: 50
-DOOR: false, closed, east, random
+SUBROOM: "food shop" [50%], lit, (25,11), (3,2)
+{
+ROOMDOOR: false, closed, south|east, random
+}
 
-SUBROOM: "tool shop", lit, (25,2), (3,3), "town"
-CHANCE: 30
-DOOR: false, closed, west, random
+SUBROOM: "tool shop" [30%], lit, (25,2), (3,3)
+{
+ROOMDOOR: false, closed, north|west|east, random
+}
 
-SUBROOM: "temple", lit, (24,6), (4,4), "town"
-DOOR: false, closed, west, random
+SUBROOM: "temple", lit, (24,6), (4,4)
+{
+ROOMDOOR: false, closed, west, random
 ALTAR:(02,01),align[0],shrine
 MONSTER: 'G', "gnomish wizard", random
 MONSTER: 'G', "gnomish wizard", random
+}
+
+FOUNTAIN: (12, 07)
+FOUNTAIN: (11, 13)
+
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watchman", random, peaceful
+MONSTER: '@', "watch captain", random, peaceful
+MONSTER:'G',"gnome",random
+MONSTER:'G',"gnome",random
+MONSTER:'G',"gnome",random
+MONSTER:'G',"gnome lord",random
+MONSTER:'Y',"monkey",random
+MONSTER:'Y',"monkey",random
+
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 TRAP: random, random
 MONSTER: 'G', "gnome", random
 MONSTER: 'G', "gnome", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 MONSTER: 'h', "dwarf", random
+}
   
 ROOM: "ordinary" , random, random, random, random
+{
 TRAP: random, random
 MONSTER: 'G', "gnome", random
+}
 
 RANDOM_CORRIDORS
   
 
+
 # Mine end level variant 1
 # "Mimic of the Mines"
 #
-MAZE: "minend-1", ' '
+LEVEL: "minend-1"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #1234567890123456789012345678901234567890123456789012345678901234567890
@@ -801,6 +1176,10 @@
 # "Gnome King's Wine Cellar"
 #
-MAZE: "minend-2", ' '
+LEVEL: "minend-2"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
+#         1         2         3         4         5         6         7
+#1234567890123456789012345678901234567890123456789012345678901234567890
 MAP
 ---------------------------------------------------------------------------
@@ -824,4 +1203,31 @@
 ENDMAP
 
+IF [50%] {
+   TERRAIN:(55,14),'-',unlit
+   TERRAIN:(56,14),'-',unlit
+   TERRAIN:(61,15),'|',unlit
+   TERRAIN:(52,5), 'S',unlit
+   DOOR:locked, (52,5)
+}
+
+IF [50%] {
+   TERRAIN:(18,1), '|',unlit
+   TERRAIN:(7,12, 8,13), unfilled, '.',unlit
+}
+
+IF [50%] {
+   TERRAIN:(49,4), '|', unlit
+   TERRAIN:(21,5), '.', unlit
+}
+
+IF [50%] {
+   IF [50%] {
+      TERRAIN:(22,1), '|', unlit
+   } ELSE {
+      TERRAIN:(50,7), '-', unlit
+      TERRAIN:(51,7), '-', unlit
+   }
+}
+
 # Dungeon Description
 FOUNTAIN:(14,13)
@@ -896,4 +1302,6 @@
 TRAP:random,random
 # Random monsters.
+MONSTER:'G',"gnome king",(10,09),hostile
+MONSTER:'G',"gnomish wizard",(11,09),hostile
 MONSTER:'G',"gnome king",random
 MONSTER:'G',"gnome lord",random
@@ -922,6 +1330,7 @@
 # Relies on some very specific behavior of MAZEWALK.
 #
-MAZE:"minend-3",'-'
-FLAGS:nommap
+LEVEL:"minend-3"
+FLAGS:nommap,mazelevel
+INIT_MAP:solidfill,'-'
 GEOMETRY:center,bottom
 MAP
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Monk.des nethack/dat/Monk.des
--- nh_orig/dat/Monk.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Monk.des	2009-09-29 16:12:36.780292381 -0400
@@ -9,6 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Mon-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Mon-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"earth elemental"), (16,'E'), (16,"xorn"), (4,'X')
 GEOMETRY:center,center
 MAP
@@ -104,5 +106,8 @@
 #
 
-MAZE: "Mon-loca",' '
+LEVEL: "Mon-loca"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"earth elemental"), (16,'E'), (16,"xorn"), (4,'X')
 GEOMETRY:center,center
 #         1         2         3         4         5         6         7 
@@ -196,6 +201,8 @@
 #
 
-MAZE: "Mon-goal", ' '
-INIT_MAP: 'L' , '.' , false , false , unlit , false
+LEVEL: "Mon-goal"
+FLAGS:mazelevel
+INIT_MAP: mines, 'L' , '.' , false , false , unlit , false
+MON_GENERATION:86%, (64,"earth elemental"), (16,'E'), (16,"xorn"), (4,'X')
 GEOMETRY:center,center
 MAP
@@ -218,5 +225,5 @@
 STAIR:(20,05),up
 # Objects
-OBJECT:'(',"lenses",place[0],blessed,0,"The Eyes of the Overworld"
+OBJECT:'(',"lenses",place[0],blessed,0,NAME:"The Eyes of the Overworld"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -272,18 +279,24 @@
 
 LEVEL: "Mon-fila"
+MON_GENERATION:86%, (64,"earth elemental"), (16,'E'), (16,"xorn"), (4,'X')
 # Random Monsters
 RANDOM_MONSTERS: 'E', 'X'
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'E', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'E', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
@@ -291,6 +304,8 @@
 MONSTER: 'X', "xorn", random
 MONSTER: 'E', "earth elemental", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -298,39 +313,52 @@
 MONSTER: 'E', random, random, hostile
 MONSTER: 'E', "earth elemental", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'X', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'E', "earth elemental", random
+}
 
 RANDOM_CORRIDORS
 
 LEVEL: "Mon-filb"
+MON_GENERATION:86%, (64,"earth elemental"), (16,'E'), (16,"xorn"), (4,'X')
 # Random Monsters
 RANDOM_MONSTERS: 'E', 'X'
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'X', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'X', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 OBJECT: random,random,random
 MONSTER: 'E', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -338,15 +366,20 @@
 MONSTER: 'E', random, random, hostile
 MONSTER: 'E', "earth elemental", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'X', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'E', "earth elemental", random
+}
 
 RANDOM_CORRIDORS
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/opthelp nethack/dat/opthelp
--- nh_orig/dat/opthelp	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/opthelp	2009-08-02 13:49:39.554408799 -0400
@@ -93,4 +93,7 @@
 disclose      the types of information you want offered at the end of the
               game  [ni na nv ng nc]
+dumpfile      the name of the file where to dump the disclosure information
+              when the game ends (only if the patch has been compiled in)
+              [none]
 fruit         the name of a fruit you enjoy eating  [slime mold]
               (basically a whimsy which NetHack uses from time to time).
@@ -121,4 +124,9 @@
               You choose a combination of top scores, scores around the top
               scores, and all of your own scores.  [!own/3 top/2 around]
+sortloot      controls the sortloot patch [none]:
+              full -- All pickup lists of items are sorted by item description
+              loot -- When inventory letters are shown, has no effect.
+                      Otherwise sorts by description
+              none -- Works the traditional way, like without the patch
 suppress_alert disable various version-specific warnings about changes
               in game play or the user interface, such as notification given
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/oracle.des nethack/dat/oracle.des
--- nh_orig/dat/oracle.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/oracle.des	2009-09-25 15:37:11.585293506 -0400
@@ -8,5 +8,16 @@
 
 ROOM: "ordinary" , lit, (3,3), (center,center), (11,9)
-NAME: "central"
+{
+
+SUBROOM: "delphi" , lit , (4,3) , (3,3)
+{
+FOUNTAIN: (0, 1)
+FOUNTAIN: (1, 0)
+FOUNTAIN: (1, 2)
+FOUNTAIN: (2, 1)
+MONSTER: '@', "Oracle", (1,1)
+ROOMDOOR: false , nodoor , random, random
+}
+
 OBJECT:'`',"statue",(0,0),"forest centaur",1
 OBJECT:'`',"statue",(0,8),"mountain centaur",1
@@ -20,17 +31,14 @@
 MONSTER: random, random, random
 
-SUBROOM: "delphi" , lit , (4,3) , (3,3), "central"
-FOUNTAIN: (0, 1)
-FOUNTAIN: (1, 0)
-FOUNTAIN: (1, 2)
-FOUNTAIN: (2, 1)
-MONSTER: '@', "Oracle", (1,1)
-DOOR: false , nodoor , random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -38,19 +46,26 @@
 MONSTER: random, random, random
 MONSTER: random, random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 MONSTER: random, random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: random, random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: random, random, random
+}
 
 RANDOM_CORRIDORS
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Priest.des nethack/dat/Priest.des
--- nh_orig/dat/Priest.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Priest.des	2009-09-29 16:12:36.721417459 -0400
@@ -9,6 +9,11 @@
 #	and receive your quest assignment.
 #
-MAZE: "Pri-strt",' '
-FLAGS: noteleport,hardfloor
+# All Priest quest levels are explicitly marked as graveyards
+# so there's less chance for undead corpses.
+#
+LEVEL: "Pri-strt"
+FLAGS: noteleport,hardfloor,mazelevel,graveyard
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"human zombie"), (16,'Z'), (16,"wraith"), (4,'W')
 GEOMETRY:center,center
 MAP
@@ -105,8 +110,9 @@
 #
 
-MAZE: "Pri-loca",' '
-FLAGS: hardfloor
+LEVEL: "Pri-loca"
+FLAGS: hardfloor,mazelevel,graveyard
 # This is a kludge to init the level as a lit field.
-INIT_MAP: '.' , '.' , false , false , lit , false
+INIT_MAP: mines, '.' , '.' , false , false , lit , false
+MON_GENERATION:86%, (64,"human zombie"), (16,'Z'), (16,"wraith"), (4,'W')
 GEOMETRY:center,center
 MAP
@@ -181,6 +187,8 @@
 #
 
-MAZE: "Pri-goal", ' '
-INIT_MAP: 'L' , '.' , false , false , unlit , false
+LEVEL: "Pri-goal"
+FLAGS:mazelevel,graveyard
+INIT_MAP: mines, 'L' , '.' , false , false , unlit , false
+MON_GENERATION:86%, (64,"human zombie"), (16,'Z'), (16,"wraith"), (4,'W')
 GEOMETRY:center,center
 MAP
@@ -203,5 +211,5 @@
 STAIR:(20,05),up
 # Objects
-OBJECT:'[',"helm of brilliance",place[0],blessed,0,"The Mitre of Holiness"
+OBJECT:'[',"helm of brilliance",place[0],blessed,0,NAME:"The Mitre of Holiness"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -265,51 +273,72 @@
 
 LEVEL: "Pri-fila"
+FLAGS:graveyard
+MON_GENERATION:86%, (64,"human zombie"), (16,'Z'), (16,"wraith"), (4,'W')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'Z', "human zombie", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 OBJECT: random,random,random
 MONSTER: 'Z', "human zombie", random
+}
 
 ROOM: "morgue" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
 TRAP: random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'W', "wraith", random
+}
 
 ROOM: "morgue" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
+}
 
 RANDOM_CORRIDORS
 
 LEVEL: "Pri-filb"
+FLAGS:graveyard
+MON_GENERATION:86%, (64,"human zombie"), (16,'Z'), (16,"wraith"), (4,'W')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'Z', "human zombie", random
 MONSTER: 'W', "wraith", random
+}
 
 ROOM: "morgue" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 OBJECT: random,random,random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
@@ -317,12 +346,16 @@
 MONSTER: 'Z', "human zombie", random
 MONSTER: 'W', "wraith", random
+}
 
 ROOM: "morgue" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
@@ -330,8 +363,11 @@
 MONSTER: 'Z', "human zombie", random
 MONSTER: 'W', "wraith", random
+}
 
 ROOM: "morgue" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
+}
 
 RANDOM_CORRIDORS
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/quest.txt nethack/dat/quest.txt
--- nh_orig/dat/quest.txt	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/quest.txt	2009-08-02 13:49:39.540409141 -0400
@@ -360,5 +360,5 @@
 "Pah!  You have betrayed the gods, %p.  You will never attain
 the glory which you aspire to.  Your failure to follow the true path has
-closed this future to you.
+closed that future to you.
 
 "I will protect these people as best I can, but soon %n will overcome
@@ -560,10 +560,10 @@
 #
 %Cc Cav 00001
-You descend through a barely familiar stairwell that you remember
+You walk through a barely familiar overgrown path that you remember
 %l showing you when you embarked upon your vision quest.
 
-You arrive back at %H, but something seems
-wrong here.  The usual smoke and glowing light of the fires of the
-outer caves are absent, and an uneasy quiet fills the damp air.
+You arrive back at %H, ... but something seems
+wrong here.  The jungle has a tense aura about it, and the beasts
+are snarling and hostile.  An uneasy quiet fills the damp air.
 %E
 %Cp Cav 00002
@@ -620,6 +620,5 @@
 %E
 %Cc Cav 00018
-"%pC!  You have sealed our fate.  You seem unable to reform yourself,
-so I must select another to take your place.
+"%pC!  You have sealed our fate by being unable to reform yourself.
 
 "Begone from %H!  You have betrayed us by choosing
@@ -640,5 +639,5 @@
 %Cc Cav 00020
 "%pC!  You have deviated from my teachings.  You no longer follow
-the path of the %a as you should.  I banish you from these caves, to
+the path of the %a as you should.  I banish you from this temple, to
 go forth and purify yourself.  Then, you might be able to accomplish this
 quest."
@@ -648,5 +647,5 @@
 great suffering among your people:
 
-"Shortly after you left on your vision quest, the caves were invaded by
+"Shortly after you left on your vision quest, the jungle was invaded by
 the creatures sent against us by %n.
 
@@ -655,10 +654,13 @@
 minions of %n managed to steal %o.
 They took it to %i and there, none of our
-%g warriors have been able to go.
+%g warriors have been able to go.  Worse, she has invoked its power
+against us, and now conflict ravages our once-peaceful jungle.
 
 "You must find %i, and within it wrest
 %o from %n.  She guards it as
 jealously as she guards all treasures she attains.  But with it,
-we can make our caves safe once more.
+we can make our jungle safe once more.  Without it, the spirit of the
+jungle cries out in pain, and the animals are crazed and attack all
+who pass near.
 
 "Please, %p, recover %o for us, and return it here."
@@ -699,10 +701,10 @@
 %E
 %Cc Cav 00035
-You %x many large claw marks on the ground.  The tunnels ahead
-of you are larger than most of those in any cave complex you have
-ever been in before.
+You %x many large claw marks on the ground.  Your brief respite 
+from the narrow jungle confines appears to be over... many paths lead
+into the trees in all directions, and stagnant pools cover the ground.
 
-Your nose detects the smell of carrion from within, and bones litter
-the sides of the tunnels.
+Your nose detects the smell of carrion from somewhere deep within, and
+unidentifiable, gnawed bones litter the nearby underbrush.
 %E
 %Cp Cav 00036
@@ -713,5 +715,5 @@
 nevertheless show signs of being scorched by fire.
 
-Bones litter the floor, and there are objects scattered everywhere.
+Bones cover the floor, and there are objects scattered everywhere.
 The air is close with the stench of sulphurous fumes.
 
@@ -784,4 +786,10 @@
     own.
 
+He takes it from your hands and does something you cannot see. You 
+feel the very trees relax as the magic-induced hatred melts away from
+the land.
+
+He returns it to you and says:
+
     To prevent further trouble, I would like you, %p,
     to take %o away with you.  It will help you as you
@@ -1149,13 +1157,13 @@
 far is a credit to thy valor, but thou art yet unprepared for
 the demands required as Our Champion.  %rA, no matter how
-pure, could never hope to defeat the foul %n.
+brave, could never hope to defeat the foul %n.
 
 "Journey forth from this place, and hone thy skills.  Return to
-Our presence when thou hast attained the noble title of %R."
+Our presence when thou hast attained the title of %R."
 %E
 %Cc Kni 00020
-"Thou dishonourest Us, %p!  Thou hast strayed from the path of
-chivalry! Go from Our presence and do penance.  Only when thou art again
-pure mayst thou return hence."
+"Thou dishonourest Us, %p!  Thou hast strayed from thine chosen 
+path!  Go from Our presence and do penance.  Only when thou 
+hast regained thy soul's direction mayst thou return hence."
 %E
 %Cc Kni 00021
@@ -2139,8 +2147,6 @@
 "Well %gp, it looks like our friend has forgotten who is the boss
 around here.  Our friend seems to think that %rp have been put in
-charge.  Wrong.  DEAD WRONG!"
+charge.  Wrong.  DEAD wrong, in fact..."
 
-Your sudden shift in surroundings prevents you from hearing the end
-of %ls curse.
 %E
 %Cc Rog 00019
@@ -2885,6 +2891,6 @@
 %Cc Val 00018
 "No, %p.  Your fate is sealed.  I must cast about for another
-champion.  Begone from my presence, and never return.  Know this, that
-you shall never succeed in this life, and Valhalla is denied to you."
+champion.  Begone from my presence, and never return.  Know that
+Valhalla shall be denied to you."
 %E
 %Cc Val 00019
@@ -3463,10 +3469,9 @@
 have done.
 
-Leave this place.  You shall never set foot at %H again.
-That which you seek is now lost forever, for without the Bell of Opening, 
-you will never be able to enter the place where he who has the Amulet 
-resides.
+Leave this place. You shall never set foot beyond %H again as long as I
+draw breath... and without the Bell of Opening, you will never be able to 
+enter the place where he who has the Amulet resides.
 
-Go now!  You are banished from this place.
+Begone from my sight!"
 %E
 #
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Ranger.des nethack/dat/Ranger.des
--- nh_orig/dat/Ranger.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Ranger.des	2009-10-05 13:36:36.539417995 -0400
@@ -9,7 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Ran-strt",'.'
-FLAGS: noteleport,hardfloor,arboreal
-INIT_MAP:'.','.',true,true,lit,false
+LEVEL: "Ran-strt"
+FLAGS: noteleport,hardfloor,arboreal,mazelevel
+INIT_MAP:mines,'.','.',true,true,lit,false
+MON_GENERATION:86%, (64,"forest centaur"), (16,'C'), (16,"scorpion"), (4,'s')
 GEOMETRY:left,center
 #1234567890123456789012345678901234567890123456789012345678901234567890
@@ -102,6 +103,8 @@
 #
 
-MAZE: "Ran-loca",' '
-FLAGS: hardfloor
+LEVEL: "Ran-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"forest centaur"), (16,'C'), (16,"scorpion"), (4,'s')
 GEOMETRY:center,center
 #1234567890123456789012345678901234567890123456789012345678901234567890
@@ -185,5 +188,8 @@
 #
 
-MAZE: "Ran-goal", ' '
+LEVEL: "Ran-goal"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"forest centaur"), (16,'C'), (16,"scorpion"), (4,'s')
 GEOMETRY:center,center
 MAP
@@ -198,5 +204,5 @@
    .        S          .         .........   .S.    .S...............   .   
    .  ...   .     ...  .         .........          .                   .   
-   . ........    .....S.+.......+....\....+........+.                   .   
+   . ........    .....S.+.......+.........+........+.                   .   
    .  ...         ...    S       .........           ..      .....      .   
    .                    ..       .........            ..      ......    .   
@@ -216,5 +222,6 @@
 NON_DIGGABLE:(00,00,75,19)
 # Objects
-OBJECT:')',"bow",(37,10),blessed,0,"The Longbow of Diana"
+OBJECT:'\',"throne",(37,10)
+OBJECT:')',"bow",(37,10),blessed,0,NAME:"The Longbow of Diana"
 OBJECT:'(',"chest",(37,10)
 OBJECT:random,random,(36,09)
@@ -294,6 +301,8 @@
 #
 
-MAZE: "Ran-fila" , ' '
-INIT_MAP: '.' , 'T', true, true, random, true
+LEVEL: "Ran-fila"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'T', true, true, random, true
+MON_GENERATION:86%, (64,"forest centaur"), (16,'C'), (16,"scorpion"), (4,'s')
 NOMAP
 #
@@ -322,6 +331,8 @@
 MONSTER: 's', "scorpion", random, hostile
 
-MAZE: "Ran-filb" , ' '
-INIT_MAP: '.' , ' ', true, true, random, true
+LEVEL: "Ran-filb"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , ' ', true, true, random, true
+MON_GENERATION:86%, (64,"forest centaur"), (16,'C'), (16,"scorpion"), (4,'s')
 NOMAP
 #
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Rogue.des nethack/dat/Rogue.des
--- nh_orig/dat/Rogue.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Rogue.des	2009-09-29 16:12:36.725332407 -0400
@@ -8,6 +8,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Rog-strt",' '
-FLAGS: noteleport, hardfloor, nommap
+LEVEL: "Rog-strt"
+FLAGS: noteleport, hardfloor, nommap, mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"leprechaun"), (16,'n'), (16,"guardian naga"), (4,'N')
 GEOMETRY:center,center
 #         1         2         3         4         5         6         7
@@ -174,5 +176,8 @@
 #
 
-MAZE: "Rog-loca",' '
+LEVEL: "Rog-loca"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"leprechaun"), (16,'n'), (16,"guardian naga"), (4,'N')
 GEOMETRY:center,center
 #         1         2         3         4         5         6         7
@@ -276,6 +281,8 @@
 #	arrival point and his location.
 #
-MAZE: "Rog-goal", ' '
-FLAGS: noteleport
+LEVEL: "Rog-goal"
+FLAGS: noteleport,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"leprechaun"), (16,'n'), (16,"guardian naga"), (4,'N')
 GEOMETRY:center,center
 #         1         2         3         4         5         6         7
@@ -314,5 +321,5 @@
 TRAP:"spiked pit",(37,07)
 # Objects
-OBJECT:'(',"skeleton key",(38,10),blessed,0,"The Master Key of Thievery"
+OBJECT:'(',"skeleton key",(38,10),blessed,0,NAME:"The Master Key of Thievery"
 OBJECT:'%',"tin",(26,12),"chameleon",0
 OBJECT:random,random,random
@@ -389,17 +396,23 @@
 #
 LEVEL: "Rog-fila"
+MON_GENERATION:86%, (64,"leprechaun"), (16,'n'), (16,"guardian naga"), (4,'N')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'l', "leprechaun", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'l', "leprechaun", random, hostile
 MONSTER: 'N', "guardian naga", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
@@ -407,6 +420,8 @@
 OBJECT: random,random,random
 MONSTER: 'n', "water nymph", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -415,6 +430,8 @@
 MONSTER: 'l', random, random, hostile
 MONSTER: 'N', "guardian naga", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
@@ -422,6 +439,8 @@
 TRAP: random, random
 MONSTER: 'l', "leprechaun", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
@@ -429,4 +448,5 @@
 MONSTER: 'l', "leprechaun", random, hostile
 MONSTER: 'n', "water nymph", random, hostile
+}
 
 RANDOM_CORRIDORS
@@ -436,17 +456,23 @@
 #
 LEVEL: "Rog-filb"
+MON_GENERATION:86%, (64,"leprechaun"), (16,'n'), (16,"guardian naga"), (4,'N')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'l', "leprechaun", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'l', "leprechaun", random, hostile
 MONSTER: 'N', "guardian naga", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
@@ -454,6 +480,8 @@
 OBJECT: random,random,random
 MONSTER: 'n', "water nymph", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -462,6 +490,8 @@
 MONSTER: 'l', random, random, hostile
 MONSTER: 'N', "guardian naga", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
@@ -469,6 +499,8 @@
 TRAP: random, random
 MONSTER: 'l', "leprechaun", random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
@@ -476,4 +508,5 @@
 MONSTER: 'l', "leprechaun", random, hostile
 MONSTER: 'n', "water nymph", random, hostile
+}
 
 RANDOM_CORRIDORS
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Samurai.des nethack/dat/Samurai.des
--- nh_orig/dat/Samurai.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Samurai.des	2009-09-29 16:12:36.780292381 -0400
@@ -9,6 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Sam-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Sam-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"wolf"), (16,'d'), (16,"stalker"), (4,'E')
 GEOMETRY:center,center
 MAP
@@ -96,6 +98,8 @@
 #
 
-MAZE: "Sam-loca",' '
-FLAGS: hardfloor
+LEVEL: "Sam-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"wolf"), (16,'d'), (16,"stalker"), (4,'E')
 GEOMETRY:center,center
 MAP
@@ -240,6 +244,8 @@
 #
 
-MAZE: "Sam-goal", ' '
-FLAGS: noteleport
+LEVEL: "Sam-goal"
+FLAGS: noteleport,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"wolf"), (16,'d'), (16,"stalker"), (4,'E')
 GEOMETRY:center,center
 MAP
@@ -278,5 +284,5 @@
 NON_DIGGABLE:(00,00,44,19)
 # Objects
-OBJECT:')',"tsurugi",(22,10),blessed,0,"The Tsurugi of Muramasa"
+OBJECT:')',"tsurugi",(22,10),blessed,0,NAME:"The Tsurugi of Muramasa"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -342,6 +348,8 @@
 #
 
-MAZE: "Sam-fila", ' '
-INIT_MAP: '.' , 'P', true, true, random, true
+LEVEL: "Sam-fila"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'P', true, true, random, true
+MON_GENERATION:86%, (64,"wolf"), (16,'d'), (16,"stalker"), (4,'E')
 NOMAP
 #
@@ -372,5 +380,8 @@
 TRAP: random, random
 
-MAZE: "Sam-filb", ' '
+LEVEL: "Sam-filb"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"wolf"), (16,'d'), (16,"stalker"), (4,'E')
 GEOMETRY:center,center
 MAP
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/sokoban.des nethack/dat/sokoban.des
--- nh_orig/dat/sokoban.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/sokoban.des	2009-10-17 11:21:33.702372954 -0400
@@ -31,8 +31,33 @@
 #   Bones files are not permitted.
 
+# Temporarily commented out 'til bugfix
+# INCLUDE "functions.des"
+
+FUNCTION soko_loot()
+{
+  # Random objects
+  OBJECT:'%',random,random
+  OBJECT:'%',random,random
+  OBJECT:'%',random,random
+  OBJECT:'%',random,random
+  OBJECT:'=',random,random
+  OBJECT:'/',random,random
+}
+
+FUNCTION soko_prize()
+{
+  IF [50%] {
+    OBJECT:'"',"amulet of reflection",place[0]
+  } ELSE {
+    OBJECT:'(',"bag of holding",place[0]
+  }
+  ENGRAVING:place[0],burn,"Elbereth"
+}
+
 
 ### Bottom (first) level of Sokoban ###
-MAZE:"soko4-1",' '
-FLAGS:noteleport,hardfloor
+LEVEL:"soko4-1"
+FLAGS:noteleport,hardfloor,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -87,15 +112,10 @@
 OBJECT:'?',"earth",(03,11)
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 
-MAZE:"soko4-2",' '
-FLAGS:noteleport,hardfloor
+LEVEL:"soko4-2"
+FLAGS:noteleport,hardfloor,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -151,16 +171,11 @@
 OBJECT:'?',"earth",(02,09)
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 
 ### Second level ###
-MAZE:"soko3-1",' '
-FLAGS:noteleport
+LEVEL:"soko3-1"
+FLAGS:noteleport,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -228,15 +243,10 @@
 TRAP:"hole",(26,10)
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 
-MAZE:"soko3-2",' '
-FLAGS:noteleport
+LEVEL:"soko3-2"
+FLAGS:noteleport,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -296,16 +306,11 @@
 TRAP:"hole",(23,10)
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 
 ### Third level ###
-MAZE:"soko2-1",' '
-FLAGS:noteleport
+LEVEL:"soko2-1"
+FLAGS:noteleport,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -362,15 +367,10 @@
 TRAP:"hole",(17,09)
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 
-MAZE:"soko2-2",' '
-FLAGS:noteleport
+LEVEL:"soko2-2"
+FLAGS:noteleport,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -428,16 +428,11 @@
 TRAP:"hole",(17,11)
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 
 ### Top (last) level of Sokoban ###
-MAZE:"soko1-1",' '
-FLAGS:noteleport
+LEVEL:"soko1-1"
+FLAGS:noteleport,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -512,11 +507,5 @@
 MONSTER:'m',"giant mimic", random, m_object "boulder"
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 # Rewards
@@ -526,10 +515,10 @@
 DOOR:closed,(17,15)
 REGION:(18,10,22,16),lit,"zoo",filled,true
-OBJECT:'(',"bag of holding",place[0]
-ENGRAVING:place[0],burn,"Elbereth"
+soko_prize()
 
 
-MAZE:"soko1-2",' '
-FLAGS:noteleport
+LEVEL:"soko1-2"
+FLAGS:noteleport,mazelevel,premapped
+INIT_MAP:solidfill,' '
 GEOMETRY:center,center
 #12345678901234567890123456789012345678901234567890
@@ -606,11 +595,5 @@
 MONSTER:'m',"giant mimic", random, m_object "boulder"
 
-# Random objects
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'%',random,random
-OBJECT:'=',random,random
-OBJECT:'/',random,random
+soko_loot()
 
 # Rewards
@@ -620,4 +603,3 @@
 DOOR:closed,(17,14)
 REGION:(18,09,22,15),lit,"zoo",filled,true
-OBJECT:'"',"amulet of reflection",place[0]
-ENGRAVING:place[0],burn,"Elbereth"
+soko_prize()
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Tourist.des nethack/dat/Tourist.des
--- nh_orig/dat/Tourist.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Tourist.des	2009-10-05 13:36:36.537418241 -0400
@@ -9,6 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Tou-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Tou-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"giant spider"), (16,'S'), (16,"forest centaur"), (4,'C')
 GEOMETRY:center,center
 MAP
@@ -16,5 +18,5 @@
 ........}}...|.......|..|.-------------------------------------------...|...
 .........}}..|.......|..|.|......|......|.............|......|......|...|...
-..........}}.|.......|..|.|......+......+.............+......+..\...|...|...
+..........}}.|.......|..|.|......+......+.............+......+......|...|...
 ...........}}}..........|.|......|......|.............|......|......|...|...
 .............}}.........|.|----S-|--S---|S----------S-|---S--|------|...|...
@@ -95,4 +97,5 @@
 MONSTER: 'C',random,random
 # Twoflower
+OBJECT:'\',"throne",(64,03)
 MONSTER:'@',"Twoflower",(64,03)
 # The treasure of Twoflower
@@ -137,6 +140,8 @@
 #
 
-MAZE: "Tou-loca",' '
-FLAGS: hardfloor
+LEVEL: "Tou-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"giant spider"), (16,'S'), (16,"forest centaur"), (4,'C')
 GEOMETRY:center,center
 MAP
@@ -152,5 +157,5 @@
 |....+.....+.........S...|...........|....|-------|........................|
 |....|.....|.........|...|.|---------|....|.........|-------|.|----------|.|
-|....|.....|---------|---|.|......|..+....|-------|.|.......|.+......S.\.|.|
+|....|.....|---------|---|.|......|..+....|-------|.|.......|.+......S...|.|
 |....|.....+.........S...|.|......|..|....|.......|.|.......|.|......|...|.|
 |-------|..|.........|---|.|+-------------------+-|.|.......+.|----------|.|
@@ -258,4 +263,5 @@
 OBJECT:random,random,random
 # Toilet paper
+OBJECT:'\',"throne",(71,11)
 OBJECT:'?',"blank paper",(71,12)
 OBJECT:'?',"blank paper",(71,12)
@@ -298,5 +304,8 @@
 #
 
-MAZE: "Tou-goal", ' '
+LEVEL: "Tou-goal"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"giant spider"), (16,'S'), (16,"forest centaur"), (4,'C')
 GEOMETRY:center,center
 MAP
@@ -385,5 +394,5 @@
 DOOR:open,(59,17)
 # Objects
-OBJECT:'(',"credit card",(04,01),blessed,0,"The Platinum Yendorian Express Card"
+OBJECT:'(',"credit card",(04,01),blessed,0,NAME:"The Platinum Yendorian Express Card"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -459,6 +468,8 @@
 #
 
-MAZE: "Tou-fila" , ' '
-INIT_MAP: '.' , ' ', true, true, random, true
+LEVEL: "Tou-fila"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , ' ', true, true, random, true
+MON_GENERATION:86%, (64,"giant spider"), (16,'S'), (16,"forest centaur"), (4,'C')
 NOMAP
 #
@@ -487,6 +498,8 @@
 MONSTER: 'C', random, random, hostile
 
-MAZE: "Tou-filb" , ' '
-INIT_MAP: '.' , ' ', true, true, random, true
+LEVEL: "Tou-filb"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , ' ', true, true, random, true
+MON_GENERATION:86%, (64,"giant spider"), (16,'S'), (16,"forest centaur"), (4,'C')
 NOMAP
 #
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/tower.des nethack/dat/tower.des
--- nh_orig/dat/tower.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/tower.des	2009-10-05 13:36:36.545418791 -0400
@@ -4,6 +4,7 @@
 #
 # Upper stage of Vlad's tower
-MAZE:"tower1",' '
-FLAGS: noteleport,hardfloor
+LEVEL:"tower1"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:half-left,center
 MAP
@@ -13,5 +14,5 @@
 |.......+.+...|
 ---+-----.-----
-  |...\.|.+.|  
+  |.....|.+.|  
 ---+-----.-----
 |.......+.+...|
@@ -22,5 +23,9 @@
 LADDER:(11,05),down
 # The lord and his court
-MONSTER:'V',"Vlad the Impaler",(06,05)
+OBJECT:'\',"throne",(06,05)
+MONSTER:'V',"Vlad the Impaler",(06,05) {
+  OBJECT:')',"two-handed sword",+1,NAME:"Lifestealer",cursed,eroded:-1
+  OBJECT:'(',"Candelabrum of Invocation"
+}
 MONSTER:'V',random,(03,09)
 MONSTER:'V',random,(07,09)
@@ -50,6 +55,7 @@
 
 # Intermediate stage of Vlad's tower
-MAZE:"tower2",' '
-FLAGS: noteleport,hardfloor
+LEVEL:"tower2"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:half-left,center
 MAP
@@ -78,8 +84,10 @@
 MONSTER:'d',"hell hound pup",place[3]
 MONSTER:'d',"winter wolf",place[4]
-CONTAINER:'(',"chest",place[5]
-OBJECT:'"',"amulet of life saving",contained
-CONTAINER:'(',"chest",place[6]
-OBJECT:'"',"amulet of strangulation",contained
+CONTAINER:'(',"chest",place[5] {
+  OBJECT:'"',"amulet of life saving"
+}
+CONTAINER:'(',"chest",place[6] {
+  OBJECT:'"',"amulet of strangulation"
+}
 OBJECT:'[',"water walking boots",place[7]
 OBJECT:'[',"crystal plate mail",place[8]
@@ -90,6 +98,7 @@
 
 # Bottom most stage of Vlad's tower
-MAZE:"tower3",' '
-FLAGS: noteleport,hardfloor
+LEVEL:"tower3"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
 GEOMETRY:half-left,center
 MAP
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Valkyrie.des nethack/dat/Valkyrie.des
--- nh_orig/dat/Valkyrie.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Valkyrie.des	2009-09-29 16:12:36.725332407 -0400
@@ -9,6 +9,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Val-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Val-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"fire ant"), (16,'a'), (16,"fire giant"), (4,'H')
 GEOMETRY:center,center
 MAP
@@ -34,4 +36,7 @@
 IIIIIIIIIIIIIIIIIIIIIIPPPIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
 ENDMAP
+
+REPLACE_TERRAIN:(00,00,75,19), 'I', 'P', lit, 10%
+
 # Dungeon Description
 REGION:(00,00,75,19),lit,"ordinary"
@@ -88,7 +93,8 @@
 #
 
-MAZE: "Val-loca",' '
-FLAGS: hardfloor
-INIT_MAP: '.' , 'I' , true , true , lit , false
+LEVEL: "Val-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP: mines, '.' , 'I' , true , true , lit , false
+MON_GENERATION:86%, (64,"fire ant"), (16,'a'), (16,"fire giant"), (4,'H')
 GEOMETRY:center,center
 MAP
@@ -174,6 +180,8 @@
 #
 
-MAZE: "Val-goal", 'L'
-INIT_MAP: '.' , 'L' , true , true , lit , false
+LEVEL: "Val-goal"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'L' , true , true , lit , false
+MON_GENERATION:86%, (64,"fire ant"), (16,'a'), (16,"fire giant"), (4,'H')
 GEOMETRY:center,center
 MAP
@@ -207,5 +215,5 @@
 DRAWBRIDGE:(17,14),north,open
 # Objects
-OBJECT:'(',"crystal ball",(17,08),blessed,5,"The Orb of Fate"
+OBJECT:'(',"crystal ball",(17,08),blessed,5,NAME:"The Orb of Fate"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -264,6 +272,8 @@
 #
 
-MAZE: "Val-fila" , 'I'
-INIT_MAP: '.' , 'I' , true , true , lit, false
+LEVEL: "Val-fila"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'I' , true , true , lit, false
+MON_GENERATION:86%, (64,"fire ant"), (16,'a'), (16,"fire giant"), (4,'H')
 NOMAP
 #
@@ -297,6 +307,8 @@
 TRAP: random, random
 
-MAZE: "Val-filb" , 'L'
-INIT_MAP: '.' , 'L' , true , true , lit, false
+LEVEL: "Val-filb"
+FLAGS:mazelevel
+INIT_MAP: mines, '.' , 'L' , true , true , lit, false
+MON_GENERATION:86%, (64,"fire ant"), (16,'a'), (16,"fire giant"), (4,'H')
 NOMAP
 #
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/Wizard.des nethack/dat/Wizard.des
--- nh_orig/dat/Wizard.des	2003-12-07 18:39:12.000000000 -0500
+++ nethack/dat/Wizard.des	2009-10-05 13:36:36.541418110 -0400
@@ -8,6 +8,8 @@
 #	and receive your quest assignment.
 #
-MAZE: "Wiz-strt",' '
-FLAGS: noteleport,hardfloor
+LEVEL: "Wiz-strt"
+FLAGS: noteleport,hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"vampire bat"), (16,'B'), (16,"xorn"), (4,'W')
 GEOMETRY:center,center
 MAP
@@ -17,5 +19,5 @@
 ........CC........-----------.......C.C...C...C....C........................
 .......C.....---------------------...C..C..C..C.............................
-......C..C...------....\....------....C.....C...............................
+......C..C...------.........------....C.....C...............................
 ........C...||....|.........|....||.........................................
 .......C....||....|.........+....||.........................................
@@ -33,4 +35,13 @@
 ......................CCC.C.................................................
 ENDMAP
+
+SPILL:(60,15), '}', west, 20, lit
+SPILL:(69,15), '}', north, 20, lit
+
+# first do cloud everywhere
+REPLACE_TERRAIN:(0,0, 75,19), '.', 'C', lit, 10%
+# then replace clouds inside the tower back to floor
+REPLACE_TERRAIN:(13,5, 33,15), 'C', '.', lit, 100%
+
 # Dungeon Description
 REGION:(00,00,75,19),lit,"ordinary"
@@ -42,4 +53,6 @@
 STAIR:(30,10),down
 # Portal arrival point
+# need to make sure it's clear
+TERRAIN:(63,06),'.',lit
 BRANCH:(63,06,63,06),(0,0,0,0)
 # Doors
@@ -53,4 +66,5 @@
 DOOR:locked,(20,10)
 # Neferet the Green, the quest leader
+OBJECT:'\',"throne",(23,05)
 MONSTER:'@',"Neferet the Green",(23,05)
 # The treasure of the quest leader
@@ -102,6 +116,8 @@
 #
 
-MAZE: "Wiz-loca",' '
-FLAGS: hardfloor
+LEVEL: "Wiz-loca"
+FLAGS: hardfloor,mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"vampire bat"), (16,'B'), (16,"xorn"), (4,'W')
 GEOMETRY:center,center
 MAP
@@ -128,4 +144,8 @@
 .............        .......................................................
 ENDMAP
+
+REPLACE_TERRAIN:(0,0,30,20), '.', 'C', lit, 15%
+REPLACE_TERRAIN:(68,0,75,20), '.', '}', lit, 25%
+
 # Dungeon Description
 REGION:(00,00,75,20),lit,"ordinary"
@@ -226,5 +246,8 @@
 #
 
-MAZE: "Wiz-goal", ' '
+LEVEL: "Wiz-goal"
+FLAGS:mazelevel
+INIT_MAP:solidfill,' '
+MON_GENERATION:86%, (64,"vampire bat"), (16,'B'), (16,"xorn"), (4,'W')
 GEOMETRY:center,center
 MAP
@@ -232,7 +255,7 @@
                                                                             
                                                                             
-                   -------------                 -------------              
-                   |...........|                 |...........|              
-            -------|...........-------------------...........|              
+            --------------------                 -------------              
+            |......|...........|                 |...........|              
+            ---S---|...........-------------------...........|              
             |......S...........|..|..|..|..|..|..|...........|              
             |......|...........|..|..|..|..|..|..|...........|              
@@ -242,7 +265,7 @@
             |......|...........|..|..|..|..|..|..|...........|              
             |......|...........|..|..|..|..|..|..|...........|              
-            -------|...........-------------------...........|              
-                   |...........|                 |...........|              
-                   -------------                 -------------              
+            ----S--|...........-------------------...........|              
+            |......|...........|                 |...........|              
+            --------------------                 -------------              
                                                                             
                                                                             
@@ -268,4 +291,6 @@
 REGION:(47,11,48,12),unlit,"ordinary"
 REGION:(50,04,60,14),lit,"ordinary"
+REGION:(13,04,18,04),lit,"ordinary"
+REGION:(13,14,18,14),lit,"ordinary"
 # Doors
 DOOR:locked,(19,06)
@@ -285,4 +310,6 @@
 DOOR:locked,(48,10)
 DOOR:locked,(49,09)
+DOOR:locked,(16,13)
+DOOR:locked,(15,05)
 # Stairs
 STAIR:(55,05),up
@@ -292,5 +319,5 @@
 ALTAR:(16,11),noncoaligned,altar
 # Objects
-OBJECT:'"',"amulet of ESP",(16,11),blessed,0,"The Eye of the Aethiopica"
+OBJECT:'"',"amulet of power",(16,11),blessed,0,NAME:"The Eye of the Aethiopica"
 OBJECT:random,random,random
 OBJECT:random,random,random
@@ -307,4 +334,8 @@
 OBJECT:random,random,random
 OBJECT:random,random,random
+OBJECT:'+',"knock",(13,14)
+OBJECT:'+',random,(18,14)
+OBJECT:'+',random,(13,04)
+OBJECT:'+',"wizard lock",(18,04)
 # Random traps
 TRAP:random,random
@@ -314,4 +345,6 @@
 TRAP:random,random
 TRAP:random,random
+TRAP:random,(16,14)
+TRAP:random,(15,04)
 # Random monsters.
 MONSTER:'@',"Dark One",(16,11)
@@ -363,16 +396,22 @@
 
 LEVEL: "Wiz-fila"
+MON_GENERATION:86%, (64,"vampire bat"), (16,'B'), (16,"xorn"), (4,'W')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'i', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'i', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
@@ -380,6 +419,8 @@
 MONSTER: 'B', "vampire bat", random
 MONSTER: 'B', "vampire bat", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -387,37 +428,50 @@
 MONSTER: 'i', random, random, hostile
 MONSTER: 'B', "vampire bat", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'i', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'B', "vampire bat", random
+}
 
 RANDOM_CORRIDORS
 
 LEVEL: "Wiz-filb"
+MON_GENERATION:86%, (64,"vampire bat"), (16,'B'), (16,"xorn"), (4,'W')
 #
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, up
 OBJECT: random,random,random
 MONSTER: 'X', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random,random,random
 MONSTER: 'i', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 OBJECT: random,random,random
 MONSTER: 'X', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 STAIR: random, down
 OBJECT: random, random, random
@@ -425,15 +479,20 @@
 MONSTER: 'i', random, random, hostile
 MONSTER: 'B', "vampire bat", random
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'i', random, random, hostile
+}
 
 ROOM: "ordinary" , random, random, random, random
+{
 OBJECT: random, random, random
 TRAP: random, random
 MONSTER: 'B', "vampire bat", random
+}
 
 RANDOM_CORRIDORS
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/dat/yendor.des nethack/dat/yendor.des
--- nh_orig/dat/yendor.des	2003-12-07 18:39:13.000000000 -0500
+++ nethack/dat/yendor.des	2009-09-01 13:37:40.254292233 -0400
@@ -6,6 +6,8 @@
 # The top (real) wizard level.
 # Keeping the Moat for old-time's sake
-MAZE:"wizard1",random
-FLAGS:noteleport,hardfloor
+LEVEL:"wizard1"
+# Must have noflipx, due to the morgue-hack (see below).
+FLAGS:noteleport,hardfloor,mazelevel,noflipx
+INIT_MAP:mazegrid,'-'
 GEOMETRY:center,center
 MAP
@@ -90,6 +92,7 @@
 
 # The middle wizard level.
-MAZE:"wizard2",random
-FLAGS:noteleport,hardfloor
+LEVEL:"wizard2"
+FLAGS:noteleport,hardfloor,mazelevel
+INIT_MAP:mazegrid,'-'
 GEOMETRY:center,center
 MAP
@@ -142,6 +145,7 @@
 # The bottom wizard level.
 # Memorialize the fakewiz setup.
-MAZE:"wizard3",random
-FLAGS:noteleport,hardfloor
+LEVEL:"wizard3"
+FLAGS:noteleport,hardfloor,mazelevel
+INIT_MAP:mazegrid,'-'
 GEOMETRY:center,center
 MAP
@@ -218,5 +222,7 @@
 # There are two of these, and we need to
 # distinguish between them for the portal.
-MAZE:"fakewiz1",random
+LEVEL:"fakewiz1"
+FLAGS:mazelevel
+INIT_MAP:mazegrid,'-'
 GEOMETRY:center,center
 MAP
@@ -247,5 +253,7 @@
 
 
-MAZE:"fakewiz2",random
+LEVEL:"fakewiz2"
+FLAGS:mazelevel
+INIT_MAP:mazegrid,'-'
 GEOMETRY:center,center
 MAP
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/doc/Guidebook.mn nethack/doc/Guidebook.mn
--- nh_orig/doc/Guidebook.mn	2003-12-07 18:39:13.000000000 -0500
+++ nethack/doc/Guidebook.mn	2009-08-02 13:49:34.150409063 -0400
@@ -1771,4 +1771,10 @@
 Name your starting dog (ex. ``dogname:Fang'').
 Cannot be set with the `O' command.
+.lp dumpfile
+The name of a file where the disclosure information is written when the
+game ends. You may use the macro %n that will be replaced with the name
+of your player character. The game must have write permissions to the
+directory where the file is written. Normally /tmp may be used for unix
+systems.
 .lp dungeon
 Set the graphics symbols for displaying the dungeon
@@ -2099,4 +2105,16 @@
 .lp "silent  "
 Suppress terminal beeps (default on).
+.lp sortloot
+Controls the behavior of the sortloot patch that sorts pickup lists for
+inventory and #loot commands and some others.
+The possible values are:
+.sd
+.si
+full - always sort the lists;
+loot - only sort the lists that don't use inventory
+       letters, like with the #loot and pickup commands;
+none - show lists the traditional way without sorting.
+.ei
+.ed
 .lp sortpack
 Sort the pack contents by type when displaying inventory (default on).
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/doc/Guidebook.tex nethack/doc/Guidebook.tex
--- nh_orig/doc/Guidebook.tex	2003-12-07 18:39:13.000000000 -0500
+++ nethack/doc/Guidebook.tex	2009-08-02 13:49:34.160408550 -0400
@@ -2210,4 +2210,11 @@
 Cannot be set with the `{\tt O}' command.
 %.lp
+\item[\ib{dumpfile}]
+The name of a file where the disclosure information is written when the
+game ends. You may use the macro %n that will be replaced with the name
+of your player character. The game must have write permissions to the
+directory where the file is written. Normally /tmp may be used for unix
+systems.
+%.lp
 \item[\ib{dungeon}]
 Set the graphics symbols for displaying the dungeon (default
@@ -2574,4 +2581,19 @@
 Suppress terminal beeps (default on).
 %.lp
+\item[\ib{sortloot}]
+Controls the behavior of the sortloot patch that sorts pickup lists for
+inventory and \#loot commands and some others.
+
+The possible values are:
+%.sd
+%.si
+{\tt full} --- always sort the lists;\\
+{\tt loot} --- only sort the lists that don't use inventory
+       letters, like with the \#loot and pickup commands;\\
+{\tt none} --- show lists the traditional way without sorting.
+%.ei
+%.ed
+%.lp
+The default is 'none', the way an unpatched game works.
 \item[\ib{sortpack}]
 Sort the pack contents by type when displaying inventory (default on).
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/doc/Guidebook.txt nethack/doc/Guidebook.txt
--- nh_orig/doc/Guidebook.txt	2003-12-07 18:39:13.000000000 -0500
+++ nethack/doc/Guidebook.txt	2009-08-02 13:49:34.157408524 -0400
@@ -2275,4 +2275,11 @@
             with the `O' command.
 
+          dumpfile
+            The name of a file where the disclosure information is
+            written when the game ends. You may use the macro %n that
+            will be replaced with the name of your player character.
+            The game must have write permissions to the directory where
+            the file is written. Normally /tmp may be used for unixes.
+
           dungeon
             Set the graphics symbols for displaying  the  dungeon  (default
@@ -2724,4 +2731,16 @@
             Suppress terminal beeps (default on).
 
+          sortloot
+               Controls the behavior of the sortloot patch that sorts
+               pickup lists for inventory and #loot commands and some
+               others.
+               The possible values are:
+
+                    full - always sort the lists
+                    loot - only sort the lists that don't use inventory
+                           letters, like with the #loot and pickup commands
+                    none - show lists the traditional way without sorting
+               The default is 'none', the way an unpatched game works.
+
           sortpack
             Sort the pack contents by type when displaying  inventory  (de-
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/align.h nethack/include/align.h
--- nh_orig/include/align.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/align.h	2009-08-02 13:49:33.026408602 -0400
@@ -13,6 +13,8 @@
 } align;
 
-/* bounds for "record" -- respect initial alignments of 10 */
-#define ALIGNLIM	(10L + (moves/200L))
+/* bounds for "record" -- respect initial alignments of 10.
+ * note that the maximum alignment is now 50, so that mortal
+ * sins always put you out of favor with your god. */
+#define ALIGNLIM	(min(50,10L + (moves/300L)))
 
 #define A_NONE	      (-128)	/* the value range of type */
@@ -40,3 +42,13 @@
 			 : ((x) == A_LAWFUL) ? AM_LAWFUL : (x) + 2)
 
+/*
+ * These will make it a bit easier to adjust alignment swings
+ * while trying to get it balanced out to where it matters...
+ */
+
+#define venial_sin() (adjalign(-5))
+#define minor_sin() (adjalign(-10))
+#define major_sin() (adjalign(-20))
+#define mortal_sin() (adjalign(-50))
+
 #endif /* ALIGN_H */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/artifact.h nethack/include/artifact.h
--- nh_orig/include/artifact.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/artifact.h	2009-08-02 13:49:33.036408503 -0400
@@ -35,5 +35,23 @@
 #define SPFX_XRAY   0x2000000L	/* gives X-RAY vision to player */
 #define SPFX_REFLECT 0x4000000L /* Reflection */
+#define SPFX_STR	  0x8000000L   /* item bestows STR 18(**) */
+#define SPFX_CON	  0x10000000L   /* item bestows CON 25 */
+#define SPFX_POLYC  0x20000000L	 /* items grants polymorph control */
 
+#define SPDF_NONE		  0x00000000L /* No special effects */
+#define SPDF_MAGIC	  0x00000001L /* Magic resistance */
+#define SPDF_FIRE		  0x00000002L /* Fire defense */
+#define SPDF_COLD		  0x00000004L /* Cold defense */
+#define SPDF_SLEEP	  0x00000008L /* Sleep defense */
+#define SPDF_DISINT	  0x00000010L /* Disintegration defense */
+#define SPDF_ELEC		  0x00000020L /* Shock defense */
+#define SPDF_POISON	  0x00000040L /* Poison defense */
+#define SPDF_ACID		  0x00000080L /* Acid defense */
+#define SPDF_BLIND	  0x00000100L /* Blinding resistance */
+#define SPDF_WERE		  0x00000200L /* Lycanthropy resistance */
+#define SPDF_DRAIN	  0x00000400L /* Drain level defense */
+#define SPDF_CONFUSE	  0x00000800L /* Confusion */
+#define SPDF_STUN		  0x00001000L /* Stunning */
+#define SPDF_ELEMENTAL 0x000000FEL	/* All elemental resistances (Dragonbane) */
 
 struct artifact {
@@ -43,5 +61,7 @@
 	unsigned long cspfx;	/* special effect just from carrying obj */
 	unsigned long mtype;	/* monster type, symbol, or flag */
-	struct attack attk, defn, cary;
+	struct attack attk;
+	unsigned long defn;	/* special defensive properties from wielding/wearing */
+	struct attack cary;
 	uchar	    inv_prop;	/* property obtained by invoking artifact */
 	aligntyp    alignment;	/* alignment of bequeathing gods */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/artilist.h nethack/include/artilist.h
--- nh_orig/include/artilist.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/artilist.h	2009-10-31 10:32:37.579669351 -0400
@@ -16,5 +16,4 @@
 
 #define     NO_ATTK	{0,0,0,0}		/* no attack */
-#define     NO_DFNS	{0,0,0,0}		/* no defense */
 #define     NO_CARY	{0,0,0,0}		/* no carry effects */
 #define     DFNS(c)	{0,c,0,0}
@@ -26,4 +25,5 @@
 #define     ELEC(a,b)	{0,AD_ELEC,a,b}		/* electrical shock */
 #define     STUN(a,b)	{0,AD_STUN,a,b}		/* magical attack */
+#define		DRST(a,b)	{0,AD_DRST,a,b}		/* poison attack */
 
 STATIC_OVL NEARDATA struct artifact artilist[] = {
@@ -39,9 +39,16 @@
 /*  dummy element #0, so that all interesting indices are non-zero */
 A("",				STRANGE_OBJECT,
-	0, 0, 0, NO_ATTK, NO_DFNS, NO_CARY, 0, A_NONE, NON_PM, NON_PM, 0L ),
+	0, 0, 0, NO_ATTK, SPDF_NONE, NO_CARY, 0, A_NONE, NON_PM, NON_PM, 0L ),
 
 A("Excalibur",			LONG_SWORD,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_SEEK|SPFX_DEFN|SPFX_INTEL|SPFX_SEARCH),0,0,
-	PHYS(5,10),	DRLI(0,0),	NO_CARY,	0, A_LAWFUL, PM_KNIGHT, NON_PM, 4000L ),
+	PHYS(5,10),	SPDF_DRAIN,	NO_CARY,	0, A_LAWFUL, PM_KNIGHT, NON_PM, 4000L ),
+/* 
+ * The Knight needed a chaotic longsword to obtain, since Excalibur
+ * will be restricted from him... 
+*/
+A("Dirge",			LONG_SWORD,
+	(SPFX_ATTK|SPFX_NOGEN|SPFX_RESTR|SPFX_DEFN|SPFX_INTEL),0,0,
+	DRST(5,0),	SPDF_DRAIN,	NO_CARY,	0, A_CHAOTIC, NON_PM, NON_PM, 3000L ),
 /*
  *	Stormbringer only has a 2 because it can drain a level,
@@ -50,5 +57,13 @@
 A("Stormbringer",		RUNESWORD,
 	(SPFX_RESTR|SPFX_ATTK|SPFX_DEFN|SPFX_INTEL|SPFX_DRLI), 0, 0,
-	DRLI(5,2),	DRLI(0,0),	NO_CARY,	0, A_CHAOTIC, NON_PM, NON_PM, 8000L ),
+	DRLI(5,2),	SPDF_DRAIN,	NO_CARY,	0, A_CHAOTIC, NON_PM, NON_PM, 8000L ),
+/*
+ * Lifestealer gets the same restrictions as Stormy, but it's designed
+ * to be generated in Vlad's hands anyway, so this isn't such a big deal.
+ * It's two-handed so players (hopefully) won't really want to use it...
+ */
+A("Lifestealer",		TWO_HANDED_SWORD,
+	(SPFX_NOGEN|SPFX_RESTR|SPFX_ATTK|SPFX_DEFN|SPFX_INTEL|SPFX_DRLI), 0, 0,
+	DRLI(5,2),	SPDF_DRAIN,	NO_CARY,	0, A_CHAOTIC, NON_PM, NON_PM, 8000L ),
 /*
  *	Mjollnir will return to the hand of the wielder when thrown
@@ -57,29 +72,27 @@
 A("Mjollnir",			WAR_HAMMER,		/* Mjo:llnir */
 	(SPFX_RESTR|SPFX_ATTK),  0, 0,
-	ELEC(5,24),	NO_DFNS,	NO_CARY,	0, A_NEUTRAL, PM_VALKYRIE, NON_PM, 4000L ),
+	ELEC(5,24),	SPDF_NONE,	NO_CARY,	0, A_NEUTRAL, PM_VALKYRIE, NON_PM, 4000L ),
 
 A("Cleaver",			BATTLE_AXE,
 	SPFX_RESTR, 0, 0,
-	PHYS(3,6),	NO_DFNS,	NO_CARY,	0, A_NEUTRAL, PM_BARBARIAN, NON_PM, 1500L ),
+	PHYS(3,6),	SPDF_NONE,	NO_CARY,	0, A_NEUTRAL, PM_BARBARIAN, NON_PM, 1500L ),
 
 A("Grimtooth",			ORCISH_DAGGER,
 	SPFX_RESTR, 0, 0,
-	PHYS(2,6),	NO_DFNS,	NO_CARY,	0, A_CHAOTIC, NON_PM, PM_ORC, 300L ),
+	PHYS(5,6),	SPDF_NONE,	NO_CARY,	0, A_CHAOTIC, NON_PM, PM_ORC, 600L ),
 /*
  *	Orcrist and Sting have same alignment as elves.
- */
-A("Orcrist",			ELVEN_BROADSWORD,
-	SPFX_DFLAG2, 0, M2_ORC,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_CHAOTIC, NON_PM, PM_ELF, 2000L ),
-
-/*
  *	The combination of SPFX_WARN and M2_something on an artifact
  *	will trigger EWarn_of_mon for all monsters that have the appropriate
  *	M2_something flags.  In Sting's case it will trigger EWarn_of_mon
- *	for M2_ORC monsters.
+ *	for M2_SPIDER monsters; in Orcrist, for M2_ORC.
  */
+A("Orcrist",			ELVEN_BROADSWORD,
+	(SPFX_WARN|SPFX_DCLAS), 0, S_ORC,
+	PHYS(5,4),	SPDF_NONE,	NO_CARY,	0, A_CHAOTIC, NON_PM, PM_ELF, 2000L ),
+
 A("Sting",			ELVEN_DAGGER,
-	(SPFX_WARN|SPFX_DFLAG2), 0, M2_ORC,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_CHAOTIC, NON_PM, PM_ELF, 800L ),
+	(SPFX_WARN|SPFX_DCLAS), 0, S_SPIDER,
+	PHYS(5,3),	SPDF_NONE,	NO_CARY,	0, A_CHAOTIC, NON_PM, PM_ELF, 800L ),
 /*
  *	Magicbane is a bit different!  Its magic fanfare
@@ -88,41 +101,41 @@
 A("Magicbane",			ATHAME,
 	(SPFX_RESTR|SPFX_ATTK|SPFX_DEFN), 0, 0,
-	STUN(3,4),	DFNS(AD_MAGM),	NO_CARY,	0, A_NEUTRAL, PM_WIZARD, NON_PM, 3500L ),
+	STUN(3,4),	SPDF_MAGIC,	NO_CARY,	0, A_NEUTRAL, PM_WIZARD, NON_PM, 3500L ),
 
 A("Frost Brand",		LONG_SWORD,
 	(SPFX_RESTR|SPFX_ATTK|SPFX_DEFN), 0, 0,
-	COLD(5,0),	COLD(0,0),	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 3000L ),
+	COLD(5,0),	SPDF_COLD,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 3000L ),
 
 A("Fire Brand",			LONG_SWORD,
 	(SPFX_RESTR|SPFX_ATTK|SPFX_DEFN), 0, 0,
-	FIRE(5,0),	FIRE(0,0),	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 3000L ),
+	FIRE(5,0),	SPDF_FIRE,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 3000L ),
 
-A("Dragonbane",			BROADSWORD,
-	(SPFX_RESTR|SPFX_DCLAS), 0, S_DRAGON,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 500L ),
+A("Dragonbane",			DWARVISH_SPEAR,
+	(SPFX_WARN|SPFX_RESTR|SPFX_DCLAS), 0, S_DRAGON,
+	PHYS(5,4),	SPDF_ELEMENTAL,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 1500L ),
 
-A("Demonbane",			LONG_SWORD,
-	(SPFX_RESTR|SPFX_DFLAG2), 0, M2_DEMON,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_LAWFUL, NON_PM, NON_PM, 2500L ),
+A("Demonbane",			SILVER_MACE,
+	(SPFX_WARN|SPFX_RESTR|SPFX_DCLAS), 0, S_DEMON,
+	PHYS(5,4),	SPDF_NONE,	NO_CARY,	0, A_LAWFUL, NON_PM, NON_PM, 2500L ),
 
 A("Werebane",			SILVER_SABER,
-	(SPFX_RESTR|SPFX_DFLAG2), 0, M2_WERE,
-	PHYS(5,0),	DFNS(AD_WERE),	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 1500L ),
+	(SPFX_WARN|SPFX_RESTR|SPFX_DCLAS|SPFX_POLYC), 0, S_WERE,
+	PHYS(5,4),	SPDF_WERE,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 1500L ),
 
 A("Grayswandir",		SILVER_SABER,
 	(SPFX_RESTR|SPFX_HALRES), 0, 0,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_LAWFUL, NON_PM, NON_PM, 8000L ),
+	PHYS(5,0),	SPDF_NONE,	NO_CARY,	0, A_LAWFUL, NON_PM, NON_PM, 8000L ),
 
-A("Giantslayer",		LONG_SWORD,
-	(SPFX_RESTR|SPFX_DFLAG2), 0, M2_GIANT,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_NEUTRAL, NON_PM, NON_PM, 200L ),
+A("Giantslayer",		SLING,
+	(SPFX_WARN|SPFX_RESTR|SPFX_DCLAS|SPFX_STR), 0, S_GIANT,
+	PHYS(5,8),	SPDF_NONE,	NO_CARY,	0, A_NEUTRAL, NON_PM, NON_PM, 1200L ),
 
 A("Ogresmasher",		WAR_HAMMER,
-	(SPFX_RESTR|SPFX_DCLAS), 0, S_OGRE,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 200L ),
+	(SPFX_WARN|SPFX_RESTR|SPFX_DCLAS|SPFX_CON), 0, S_OGRE,
+	PHYS(5,4),	SPDF_NONE,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 1200L ),
 
 A("Trollsbane",			MORNING_STAR,
-	(SPFX_RESTR|SPFX_DCLAS), 0, S_TROLL,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 200L ),
+	(SPFX_WARN|SPFX_RESTR|SPFX_DCLAS|SPFX_REGEN), 0, S_TROLL,
+	PHYS(5,4),	SPDF_NONE,	NO_CARY,	0, A_NONE, NON_PM, NON_PM, 1200L ),
 /*
  *	Two problems:  1) doesn't let trolls regenerate heads,
@@ -132,5 +145,5 @@
 A("Vorpal Blade",		LONG_SWORD,
 	(SPFX_RESTR|SPFX_BEHEAD), 0, 0,
-	PHYS(5,1),	NO_DFNS,	NO_CARY,	0, A_NEUTRAL, NON_PM, NON_PM, 4000L ),
+	PHYS(5,1),	SPDF_NONE,	NO_CARY,	0, A_NEUTRAL, NON_PM, NON_PM, 4000L ),
 /*
  *	Ah, never shall I forget the cry,
@@ -143,9 +156,13 @@
 A("Snickersnee",		KATANA,
 	SPFX_RESTR, 0, 0,
-	PHYS(0,8),	NO_DFNS,	NO_CARY,	0, A_LAWFUL, PM_SAMURAI, NON_PM, 1200L ),
+	PHYS(5,8),	SPDF_NONE,	NO_CARY,	0, A_LAWFUL, PM_SAMURAI, NON_PM, 1200L ),
 
-A("Sunsword",			LONG_SWORD,
-	(SPFX_RESTR|SPFX_DFLAG2), 0, M2_UNDEAD,
-	PHYS(5,0),	DFNS(AD_BLND),	NO_CARY,	0, A_LAWFUL, NON_PM, NON_PM, 1500L ),
+A("Sunsword",			SILVER_LONG_SWORD,
+	(SPFX_WARN|SPFX_RESTR|SPFX_DCLAS), 0, S_UNDEAD,
+	PHYS(5,4),	SPDF_BLIND,	NO_CARY,	0, A_LAWFUL, NON_PM, NON_PM, 1500L ),
+
+A("Keolewa",CLUB,
+	SPFX_RESTR, 0, 0,
+	PHYS(5,6), SPDF_NONE, NO_CARY, 0, A_NEUTRAL, PM_CAVEMAN, NON_PM, 1000L ),
 
 /*
@@ -155,5 +172,5 @@
 A("The Orb of Detection",	CRYSTAL_BALL,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL), (SPFX_ESP|SPFX_HSPDAM), 0,
-	NO_ATTK,	NO_DFNS,	CARY(AD_MAGM),
+	NO_ATTK,	SPDF_NONE,	CARY(AD_MAGM),
 	INVIS,		A_LAWFUL, PM_ARCHEOLOGIST, NON_PM, 2500L ),
 
@@ -161,10 +178,10 @@
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL), SPFX_STLTH, 0,
 	/* this stone does double damage if used as a projectile weapon */
-	PHYS(5,0),	NO_DFNS,	NO_CARY,
+	PHYS(5,0),	SPDF_NONE,	NO_CARY,
 	LEVITATION,	A_NEUTRAL, PM_BARBARIAN, NON_PM, 2500L ),
 
 A("The Sceptre of Might",	MACE,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_DALIGN), 0, 0,
-	PHYS(5,0),	NO_DFNS,	CARY(AD_MAGM),
+	PHYS(5,0),	SPDF_NONE,	CARY(AD_MAGM),
 	CONFLICT,	A_LAWFUL, PM_CAVEMAN, NON_PM, 2500L ),
 
@@ -179,25 +196,26 @@
 A("The Staff of Aesculapius",	QUARTERSTAFF,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_ATTK|SPFX_INTEL|SPFX_DRLI|SPFX_REGEN), 0,0,
-	DRLI(0,0),	DRLI(0,0),	NO_CARY,
+	DRLI(0,0),	SPDF_DRAIN,	NO_CARY,
 	HEALING,	A_NEUTRAL, PM_HEALER, NON_PM, 5000L ),
 
 A("The Magic Mirror of Merlin", MIRROR,
-	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_SPEAK), SPFX_ESP, 0,
-	NO_ATTK,	NO_DFNS,	CARY(AD_MAGM),
+	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_SPEAK|SPFX_REFLECT), 
+	(SPFX_REFLECT|SPFX_ESP|SPFX_HSPDAM), 0,
+	NO_ATTK,	SPDF_NONE,	NO_CARY,
 	0,		A_LAWFUL, PM_KNIGHT, NON_PM, 1500L ),
 
 A("The Eyes of the Overworld",	LENSES,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_XRAY), 0, 0,
-	NO_ATTK,	NO_DFNS,	CARY(AD_MAGM),
+	NO_ATTK,	SPDF_NONE,	CARY(AD_MAGM),
 	ENLIGHTENING,	A_NEUTRAL,	 PM_MONK, NON_PM, 2500L ),
 
 A("The Mitre of Holiness",	HELM_OF_BRILLIANCE,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_DFLAG2|SPFX_INTEL), 0, M2_UNDEAD,
-	NO_ATTK,	NO_DFNS,	CARY(AD_FIRE),
+	NO_ATTK,	SPDF_NONE,	CARY(AD_FIRE),
 	ENERGY_BOOST,	A_LAWFUL, PM_PRIEST, NON_PM, 2000L ),
 
 A("The Longbow of Diana", BOW,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_REFLECT), SPFX_ESP, 0,
-	PHYS(5,0),	NO_DFNS,	NO_CARY,
+	PHYS(5,0),	SPDF_NONE,	NO_CARY,
 	CREATE_AMMO, A_CHAOTIC, PM_RANGER, NON_PM, 4000L ),
 
@@ -205,10 +223,10 @@
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_SPEAK),
 		(SPFX_WARN|SPFX_TCTRL|SPFX_HPHDAM), 0,
-	NO_ATTK,	NO_DFNS,	NO_CARY,
+	NO_ATTK,	SPDF_NONE,	NO_CARY,
 	UNTRAP,		A_CHAOTIC, PM_ROGUE, NON_PM, 3500L ),
 
 A("The Tsurugi of Muramasa",	TSURUGI,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_BEHEAD|SPFX_LUCK), 0, 0,
-	PHYS(0,8),	NO_DFNS,	NO_CARY,
+	PHYS(0,8),	SPDF_NONE,	NO_CARY,
 	0,		A_LAWFUL, PM_SAMURAI, NON_PM, 4500L ),
 
@@ -217,5 +235,5 @@
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_DEFN),
 		(SPFX_ESP|SPFX_HSPDAM), 0,
-	NO_ATTK,	NO_DFNS,	CARY(AD_MAGM),
+	NO_ATTK,	SPDF_NONE,	CARY(AD_MAGM),
 	CHARGE_OBJ,	A_NEUTRAL, PM_TOURIST, NON_PM, 7000L ),
 #endif
@@ -223,11 +241,11 @@
 A("The Orb of Fate",		CRYSTAL_BALL,
 	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_LUCK),
-		(SPFX_WARN|SPFX_HSPDAM|SPFX_HPHDAM), 0,
-	NO_ATTK,	NO_DFNS,	NO_CARY,
+		(SPFX_WARN|SPFX_HPHDAM), 0,
+	NO_ATTK,	SPDF_NONE,	NO_CARY,
 	LEV_TELE,	A_NEUTRAL, PM_VALKYRIE, NON_PM, 3500L ),
 
-A("The Eye of the Aethiopica",	AMULET_OF_ESP,
-	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL), (SPFX_EREGEN|SPFX_HSPDAM), 0,
-	NO_ATTK,	NO_DFNS,	CARY(AD_MAGM),
+A("The Eye of the Aethiopica",	AMULET_OF_POWER,
+	(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL), (SPFX_ESP|SPFX_HSPDAM), 0,
+	NO_ATTK,	SPDF_NONE,	CARY(AD_MAGM),
 	CREATE_PORTAL,	A_NEUTRAL, PM_WIZARD, NON_PM, 4000L ),
 
@@ -235,5 +253,5 @@
  *  terminator; otyp must be zero
  */
-A(0, 0, 0, 0, 0, NO_ATTK, NO_DFNS, NO_CARY, 0, A_NONE, NON_PM, NON_PM, 0L )
+A(0, 0, 0, 0, 0, NO_ATTK, SPDF_NONE, NO_CARY, 0, A_NONE, NON_PM, NON_PM, 0L )
 
 };	/* artilist[] (or artifact_names[]) */
@@ -243,5 +261,4 @@
 #ifndef MAKEDEFS_C
 #undef	NO_ATTK
-#undef	NO_DFNS
 #undef	DFNS
 #undef	PHYS
@@ -251,4 +268,5 @@
 #undef	ELEC
 #undef	STUN
+#undef	DRST
 #endif
 
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/color.h nethack/include/color.h
--- nh_orig/include/color.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/color.h	2009-09-07 11:17:28.044650941 -0400
@@ -6,4 +6,10 @@
 #define COLOR_H
 
+#ifdef MENU_COLOR
+# ifdef MENU_COLOR_REGEX
+#  include <regex.h>
+# endif
+#endif
+
 /*
  * The color scheme used is tailored for an IBM PC.  It consists of the
@@ -50,3 +56,38 @@
 #define HI_ZAP		CLR_BRIGHT_BLUE
 
+#ifdef MENU_COLOR
+struct menucoloring {
+# ifdef MENU_COLOR_REGEX
+#  ifdef MENU_COLOR_REGEX_POSIX
+    regex_t match;
+#  else
+    struct re_pattern_buffer match;
+#  endif
+# else
+    char *match;
+# endif
+    int color, attr;
+    struct menucoloring *next;
+};
+#endif /* MENU_COLOR */
+
+#ifdef STATUS_COLORS
+struct color_option {
+    int color;
+    int attr_bits;
+};
+
+struct percent_color_option {
+	int percentage;
+	struct color_option color_option;
+	const struct percent_color_option *next;
+};
+
+struct text_color_option {
+	const char *text;
+	struct color_option color_option;
+	const struct text_color_option *next;
+};
+#endif
+
 #endif /* COLOR_H */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/config.h nethack/include/config.h
--- nh_orig/include/config.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/config.h	2009-10-06 11:46:30.298418070 -0400
@@ -144,14 +144,17 @@
 #ifndef WIZARD		/* allow for compile-time or Makefile changes */
 # ifndef KR1ED
-#  define WIZARD  "wizard" /* the person allowed to use the -D option */
+#  define WIZARD  "derek" /* the person allowed to use the -D option */
 # else
 #  define WIZARD
-#  define WIZARD_NAME "wizard"
+#  define WIZARD_NAME "derek"
 # endif
 #endif
 
 #define LOGFILE "logfile"	/* larger file for debugging purposes */
+#define XLOGFILE "xlogfile" /* even larger logfile */
 #define NEWS "news"		/* the file containing the latest hack news */
 #define PANICLOG "paniclog"	/* log of panic and impossible events */
+#define DUMP_LOG				 /* turn on dumping */
+#define DUMP_FN "dumps/%n.lastlog"	 /* dump goes here */
 
 /*
@@ -170,9 +173,9 @@
 #ifdef UNIX
 /* path and file name extension for compression program */
-#define COMPRESS "/usr/bin/compress"	/* Lempel-Ziv compression */
-#define COMPRESS_EXTENSION ".Z"		/* compress's extension */
+/* #define COMPRESS "/usr/bin/compress"	 Lempel-Ziv compression */
+/* #define COMPRESS_EXTENSION ".Z"	 compress's extension */
 /* An example of one alternative you might want to use: */
-/* #define COMPRESS "/usr/local/bin/gzip" */	/* FSF gzip compression */
-/* #define COMPRESS_EXTENSION ".gz" */		/* normal gzip extension */
+#define COMPRESS "/usr/bin/gzip" /* FSF gzip compression */
+#define COMPRESS_EXTENSION ".gz" 	/* normal gzip extension */
 #endif
 
@@ -186,5 +189,5 @@
  *	for detailed configuration.
  */
-/* #define DLB */	/* not supported on all platforms */
+#define DLB /* not supported on all platforms */
 
 /*
@@ -215,5 +218,5 @@
  * Of course SECURE is meaningful only if HACKDIR is defined.
  */
-/* #define SECURE */	/* do setuid(getuid()) after chdir() */
+#define SECURE 	/* do setuid(getuid()) after chdir() */
 
 /*
@@ -301,5 +304,5 @@
  */
 
-/* #define VISION_TABLES */ /* use vision tables generated at compile time */
+#define VISION_TABLES /* use vision tables generated at compile time */
 #ifndef VISION_TABLES
 # ifndef NO_MACRO_CPATH
@@ -328,4 +331,5 @@
 /* difficulty */
 #define ELBERETH	/* Engraving the E-word repels monsters */
+#define SORTLOOT
 /* I/O */
 #define REDO		/* support for redoing last command - DGK */
@@ -339,5 +343,25 @@
 
 #define EXP_ON_BOTL	/* Show experience on bottom line */
-/* #define SCORE_ON_BOTL */	/* added by Gary Erickson (erickson@ucivax) */
+#define SCORE_ON_BOTL /* added by Gary Erickson (erickson@ucivax) */
+
+/* #define REALTIME_ON_BOTL */  /* Show elapsed time on bottom line.  Note:
+                                 * this breaks savefile compatibility. */
+
+/* The options in this section require the extended logfile support */
+#ifdef XLOGFILE
+#define RECORD_CONDUCT  /* Record conducts kept in logfile */
+#define RECORD_TURNS    /* Record turns elapsed in logfile */
+#define RECORD_ACHIEVE  /* Record certain notable achievements in the
+                         * logfile.  Note: this breaks savefile compatibility
+                         * due to the addition of the u_achieve struct. */
+#define RECORD_REALTIME /* Record the amount of actual playing time (in
+                         * seconds) in the record file.  Note: this breaks
+                         * savefile compatibility. */
+#define RECORD_START_END_TIME /* Record to-the-second starting and ending
+                               * times; stored as 32-bit values obtained
+                               * from time(2) (seconds since the Epoch.) */
+#define RECORD_GENDER0   /* Record initial gender in logfile */
+#define RECORD_ALIGN0   /* Record initial alignment in logfile */
+#endif
 
 /*
@@ -349,6 +373,23 @@
  */
 
-/*#define GOLDOBJ */	/* Gold is kept on obj chains - Helge Hafting */
-/*#define AUTOPICKUP_EXCEPTIONS */ /* exceptions to autopickup */
+#if defined(TTY_GRAPHICS) || defined(MSWIN_GRAPHICS)
+# define MENU_COLOR
+# define MENU_COLOR_REGEX
+/* if MENU_COLOR_REGEX is defined, use regular expressions (regex.h,
+ * GNU specific functions by default, POSIX functions with
+ * MENU_COLOR_REGEX_POSIX).
+ *
+ * POSIX is required for OSX and possibly others.
+ *
+ * otherwise use pmatch() to match menu color lines.
+ * pmatch() provides basic globbing: '*' and '?' wildcards.
+ */
+#endif
+
+#define STATUS_COLORS
+#define GOLDOBJ /* Gold is kept on obj chains - Helge Hafting */
+#define AUTOPICKUP_EXCEPTIONS /* exceptions to autopickup */
+#define WHEREIS_FILE /* Write out player's current location to player.whereis */
+#define WISH_TRACKER /* Write all wishes to a tracking file */
 
 /* End of Section 5 */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/decl.h nethack/include/decl.h
--- nh_orig/include/decl.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/decl.h	2009-11-22 07:19:36.043482113 -0500
@@ -28,4 +28,5 @@
 
 E NEARDATA int multi;
+E char multi_txt[BUFSZ];
 #if 0
 E NEARDATA int warnlevel;
@@ -73,4 +74,8 @@
     d_level	d_qstart_level, d_qlocate_level, d_nemesis_level;
     d_level	d_knox_level;
+#ifdef RECORD_ACHIEVE
+    d_level     d_mineend_level;
+    d_level     d_sokoend_level;
+#endif
 } dungeon_topology;
 /* macros for accesing the dungeon levels by their old names */
@@ -105,4 +110,8 @@
 #define nemesis_level		(dungeon_topology.d_nemesis_level)
 #define knox_level		(dungeon_topology.d_knox_level)
+#ifdef RECORD_ACHIEVE
+#define mineend_level           (dungeon_topology.d_mineend_level)
+#define sokoend_level           (dungeon_topology.d_sokoend_level)
+#endif
 
 E NEARDATA stairway dnstair, upstair;		/* stairs up and down */
@@ -185,4 +194,7 @@
 #endif
 E char killer_buf[BUFSZ];
+#ifdef DUMP_LOG
+E char dump_fn[];		/* dumpfile name (dump patch) */
+#endif
 E const char *configfile;
 E NEARDATA char plname[PL_NSIZ];
@@ -244,5 +256,5 @@
 #endif
 	*uskin, *uamul, *uleft, *uright, *ublindf,
-	*uwep, *uswapwep, *uquiver;
+	*uwep, *uswapwep, *uquiver, *ulauncher;
 
 E NEARDATA struct obj *uchain;		/* defined only when punished */
@@ -252,4 +264,7 @@
 E NEARDATA struct obj zeroobj;		/* init'd and defined in decl.c */
 
+#include "engrave.h"
+E struct engr *head_engr;
+
 #include "you.h"
 E NEARDATA struct you u;
@@ -262,4 +277,6 @@
 E NEARDATA struct monst youmonst;	/* init'd and defined in decl.c */
 E NEARDATA struct monst *mydogs, *migrating_mons;
+E NEARDATA struct monst* polemonst;
+E NEARDATA struct monst* ukiller;
 
 E NEARDATA struct mvitals {
@@ -386,4 +403,38 @@
 #endif /* AUTOPICKUP_EXCEPTIONS */
 
+#ifdef RECORD_ACHIEVE
+struct u_achieve {
+        Bitfield(get_bell,1);        /* You have obtained the bell of 
+                                      * opening */
+        Bitfield(get_candelabrum,1); /* You have obtained the candelabrum */
+        Bitfield(get_book,1);        /* You have obtained the book of 
+                                      * the dead */
+        Bitfield(enter_gehennom,1);  /* Entered Gehennom (including the 
+                                      * Valley) by any means */
+        Bitfield(perform_invocation,1); /* You have performed the invocation
+                                         * ritual */
+        Bitfield(get_amulet,1);      /* You have obtained the amulet
+                                      * of Yendor */
+        Bitfield(ascended,1);        /* You ascended to demigod[dess]hood.
+                                      * Not quite the same as 
+                                      * u.uevent.ascended. */
+        Bitfield(get_luckstone,1);   /* You obtained the luckstone at the
+                                      * end of the mines. */
+        Bitfield(finish_sokoban,1);  /* You obtained the sokoban prize. */
+        Bitfield(killed_medusa,1);   /* You defeated Medusa. */
+};
+
+E struct u_achieve achieve;
+#endif
+
+#if defined(RECORD_REALTIME) || defined(REALTIME_ON_BOTL)
+E struct realtime_data {
+  time_t realtime;    /* Amount of actual playing time up until the last time
+                       * the game was restored. */
+  time_t restoretime; /* The time that the game was started or restored. */
+  time_t last_displayed_time; /* Last time displayed on the status line */
+} realtime_data;
+#endif /* RECORD_REALTIME || REALTIME_ON_BOTL */
+
 #undef E
 
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/dungeon.h nethack/include/dungeon.h
--- nh_orig/include/dungeon.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/dungeon.h	2009-09-07 11:23:57.339293253 -0400
@@ -122,4 +122,8 @@
 #define Is_nemesis(x)		(on_level(x, &nemesis_level))
 #define Is_knox(x)		(on_level(x, &knox_level))
+#ifdef RECORD_ACHIEVE
+#define Is_mineend_level(x)     (on_level(x, &mineend_level))
+#define Is_sokoend_level(x)     (on_level(x, &sokoend_level))
+#endif
 
 #define In_sokoban(x)		((x)->dnum == sokoban_dnum)
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/eshk.h nethack/include/eshk.h
--- nh_orig/include/eshk.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/eshk.h	2009-11-23 13:59:51.796398963 -0500
@@ -43,3 +43,6 @@
 #define ANGRY(mon)	(!NOTANGRY(mon))
 
+#define match_shkrace(mon) ((urace.malenum == (mon)->mnum) || \
+				(urace.malenum == PM_ELF && (mon)->mnum == PM_GREEN_ELF))
+
 #endif /* ESHK_H */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/extern.h nethack/include/extern.h
--- nh_orig/include/extern.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/extern.h	2009-12-03 16:14:46.398274142 -0500
@@ -26,4 +26,7 @@
 E void NDECL(newgame);
 E void FDECL(welcome, (BOOLEAN_P));
+#if defined(RECORD_REALTIME) || defined(REALTIME_ON_BOTL)
+E time_t NDECL(get_realtime);
+#endif
 
 /* ### apply.c ### */
@@ -132,4 +135,8 @@
 E const char *FDECL(rank_of, (int,SHORT_P,BOOLEAN_P));
 E void NDECL(bot);
+#ifdef DUMP_LOG
+E void FDECL(bot1str, (char *));
+E void FDECL(bot2str, (char *));
+#endif
 
 /* ### cmd.c ### */
@@ -167,4 +174,8 @@
 E void FDECL(enlightenment, (int));
 E void FDECL(show_conduct, (int));
+#ifdef DUMP_LOG
+E void FDECL(dump_enlightenment, (int));
+E void FDECL(dump_conduct, (int));
+#endif
 E int FDECL(xytod, (SCHAR_P,SCHAR_P));
 E void FDECL(dtoxy, (coord *,int));
@@ -243,4 +254,5 @@
 E void FDECL(rot_organic, (genericptr_t, long));
 E void FDECL(rot_corpse, (genericptr_t, long));
+E void NDECL(get_coal);
 #if 0
 E void FDECL(bury_monst, (struct monst *));
@@ -282,4 +294,7 @@
 E void NDECL(cls);
 E void FDECL(flush_screen, (int));
+#ifdef DUMP_LOG
+E void NDECL(dump_screen);
+#endif
 E int FDECL(back_to_glyph, (XCHAR_P,XCHAR_P));
 E int FDECL(zapdir_to_glyph, (int,int,int));
@@ -554,4 +569,8 @@
 E void FDECL(done, (int));
 E void FDECL(container_contents, (struct obj *,BOOLEAN_P,BOOLEAN_P));
+#ifdef DUMP_LOG
+E void FDECL(dump, (char *, char *));
+E void FDECL(do_containerconts, (struct obj *,BOOLEAN_P,BOOLEAN_P,BOOLEAN_P,BOOLEAN_P));
+#endif
 E void FDECL(terminate, (int));
 E int NDECL(num_genocides);
@@ -661,4 +680,12 @@
 E void NDECL(really_close);
 #endif
+#ifdef WHEREIS_FILE
+E void NDECL(touch_whereis);
+E void NDECL(delete_whereis);
+#endif
+#ifdef WISH_TRACKER
+E void FDECL(trackwish,(char *));
+E void FDECL(makeannounce,(char *));
+#endif
 
 /* ### fountain.c ### */
@@ -695,7 +722,8 @@
 E void NDECL(lookaround);
 E int NDECL(monster_nearby);
-E void FDECL(nomul, (int));
+E void FDECL(nomul, (int, const char *));
 E void FDECL(unmul, (const char *));
 E void FDECL(losehp, (int,const char *,BOOLEAN_P));
+E int FDECL(gainmaxhp, (int));
 E int NDECL(weight_cap);
 E int NDECL(inv_weight);
@@ -748,4 +776,5 @@
 E int NDECL(phase_of_the_moon);
 E boolean NDECL(friday_13th);
+E boolean NDECL(christmas);
 E int NDECL(night);
 E int NDECL(midnight);
@@ -791,4 +820,7 @@
 E int NDECL(ddoinv);
 E char FDECL(display_inventory, (const char *,BOOLEAN_P));
+#ifdef DUMP_LOG
+E char FDECL(dump_inventory, (const char *,BOOLEAN_P,BOOLEAN_P));
+#endif
 E int FDECL(display_binventory, (int,int,BOOLEAN_P));
 E struct obj *FDECL(display_cinventory,(struct obj *));
@@ -860,5 +892,5 @@
 E boolean FDECL(picking_at, (int,int));
 E void NDECL(reset_pick);
-E int FDECL(pick_lock, (struct obj *));
+E int FDECL(pick_lock, (struct obj *,int,int));
 E int NDECL(doforce);
 E boolean FDECL(boxlock, (struct obj *,struct obj *));
@@ -953,4 +985,5 @@
 
 E int FDECL(fightm, (struct monst *));
+E boolean FDECL(resist_conflict, (struct monst *));
 E int FDECL(mattackm, (struct monst *,struct monst *));
 E int FDECL(noattacks, (struct permonst *));
@@ -996,6 +1029,7 @@
 E void FDECL(add_subroom, (struct mkroom *,int,int,int,int,
 			   BOOLEAN_P,SCHAR_P,BOOLEAN_P));
-E void NDECL(makecorridors);
+E void FDECL(makecorridors, (int));
 E void FDECL(add_door, (int,int,struct mkroom *));
+E void NDECL(mkpoolroom);
 E void NDECL(mklev);
 #ifdef SPECIALIZATION
@@ -1011,4 +1045,5 @@
 E void FDECL(mkstairs, (XCHAR_P,XCHAR_P,CHAR_P,struct mkroom *));
 E void NDECL(mkinvokearea);
+E void FDECL(wallwalk_right, (XCHAR_P,XCHAR_P,SCHAR_P,SCHAR_P,int));
 
 /* ### mkmap.c ### */
@@ -1020,5 +1055,6 @@
 
 E void FDECL(wallification, (int,int,int,int));
-E void FDECL(walkfrom, (int,int));
+E void FDECL(wall_extends, (int,int,int,int));
+E void FDECL(walkfrom, (int,int, SCHAR_P));
 E void FDECL(makemaz, (const char *));
 E void FDECL(mazexy, (coord *));
@@ -1072,4 +1108,5 @@
 E int FDECL(add_to_minv, (struct monst *, struct obj *));
 E struct obj *FDECL(add_to_container, (struct obj *, struct obj *));
+E long FDECL(get_container_weight, (struct obj *));
 E void FDECL(add_to_migration, (struct obj *));
 E void FDECL(add_to_buried, (struct obj *));
@@ -1083,4 +1120,5 @@
 /* ### mkroom.c ### */
 
+E struct mkroom * FDECL(pick_room,(BOOLEAN_P));
 E void FDECL(mkroom, (int));
 E void FDECL(fill_zoo, (struct mkroom *));
@@ -1152,4 +1190,5 @@
 E boolean FDECL(angry_guards, (BOOLEAN_P));
 E void NDECL(pacify_guards);
+E boolean FDECL(damage_mon,(struct monst*,int,int));
 
 /* ### mondata.c ### */
@@ -1162,4 +1201,5 @@
 E boolean FDECL(resists_magm, (struct monst *));
 E boolean FDECL(resists_blnd, (struct monst *));
+E boolean FDECL(vulnerable_to, (struct monst *,int));
 E boolean FDECL(can_blnd, (struct monst *,struct monst *,UCHAR_P,struct obj *));
 E boolean FDECL(ranged_attk, (struct permonst *));
@@ -1361,4 +1401,8 @@
 E char *FDECL(corpse_xname, (struct obj *,BOOLEAN_P));
 E char *FDECL(cxname, (struct obj *));
+E void FDECL(add_erosion_words, (struct obj *, char *));
+#ifdef SORTLOOT
+E char *FDECL(cxname2, (struct obj *));
+#endif
 E char *FDECL(killer_xname, (struct obj *));
 E const char *FDECL(singular, (struct obj *,char *(*)(OBJ_P)));
@@ -1406,4 +1450,7 @@
 E void NDECL(free_autopickup_exceptions);
 #endif /* AUTOPICKUP_EXCEPTIONS */
+#ifdef MENU_COLOR
+E boolean FDECL(add_menu_coloring, (char *));
+#endif /* MENU_COLOR */
 
 /* ### pager.c ### */
@@ -1544,4 +1591,8 @@
 E void FDECL(set_itimeout, (long *,long));
 E void FDECL(incr_itimeout, (long *,int));
+E void FDECL(incr_resistance, (long *,int));
+E void FDECL(decr_resistance, (long *,int));
+E int FDECL(how_resistant, (int));
+E int FDECL(resist_reduce, (int,int));
 E void FDECL(make_confused, (long,BOOLEAN_P));
 E void FDECL(make_stunned, (long,BOOLEAN_P));
@@ -1624,5 +1675,5 @@
 E void FDECL(com_pager, (int));
 E void FDECL(qt_pager, (int));
-E struct permonst *NDECL(qt_montype);
+E char *FDECL(string_subst, (char *));
 
 /* ### random.c ### */
@@ -1677,5 +1728,5 @@
 E void FDECL(save_regions, (int,int));
 E void FDECL(rest_regions, (int,BOOLEAN_P));
-E NhRegion* FDECL(create_gas_cloud, (XCHAR_P, XCHAR_P, int, int));
+E NhRegion* FDECL(create_gas_cloud, (XCHAR_P, XCHAR_P, int, size_t));
 
 /* ### restore.c ### */
@@ -1831,4 +1882,5 @@
 E char *FDECL(shk_your, (char *,struct obj *));
 E char *FDECL(Shk_Your, (char *,struct obj *));
+E void FDECL(shk_holler, (struct monst*));
 
 /* ### shknam.c ### */
@@ -1941,4 +1993,5 @@
 E void FDECL(tele_trap, (struct trap *));
 E void FDECL(level_tele_trap, (struct trap *));
+E boolean FDECL(rloc_pos_ok, (int,int,struct monst *));
 E void FDECL(rloc_to, (struct monst *,int,int));
 E boolean FDECL(rloc, (struct monst *, BOOLEAN_P));
@@ -1987,4 +2040,7 @@
 
 E void FDECL(topten, (int));
+#ifdef LOGFILE
+E void FDECL(write_log_entry, (int,long));
+#endif
 E void FDECL(prscore, (int,char **));
 E struct obj *FDECL(tt_oname, (struct obj *));
@@ -2238,4 +2294,7 @@
 E int NDECL(dbon);
 E int NDECL(enhance_weapon_skill);
+#ifdef DUMP_LOG
+E void NDECL(dump_weapon_skill);
+#endif
 E void FDECL(unrestrict_weapon_skill, (int));
 E void FDECL(use_skill, (int,int));
@@ -2260,8 +2319,10 @@
 E void FDECL(setuwep, (struct obj *));
 E void FDECL(setuqwep, (struct obj *));
+E void FDECL(setulauncher, (struct obj *));
 E void FDECL(setuswapwep, (struct obj *));
 E int NDECL(dowield);
 E int NDECL(doswapweapon);
 E int NDECL(dowieldquiver);
+E int NDECL(dowieldlauncher);
 E boolean FDECL(wield_tool, (struct obj *,const char *));
 E int NDECL(can_twoweapon);
@@ -2271,6 +2332,8 @@
 E void NDECL(uswapwepgone);
 E void NDECL(uqwepgone);
+E void NDECL(ulwepgone);
 E void NDECL(untwoweapon);
-E void FDECL(erode_obj, (struct obj *,BOOLEAN_P,BOOLEAN_P));
+E boolean FDECL(_erode_obj, (struct obj *,int));
+E void FDECL(erode_obj, (struct obj *,BOOLEAN_P,BOOLEAN_P,BOOLEAN_P));
 E int FDECL(chwepon, (struct obj *,int));
 E int FDECL(welded, (struct obj *));
@@ -2293,5 +2356,5 @@
 E void NDECL(clonewiz);
 E int NDECL(pick_nasty);
-E int FDECL(nasty, (struct monst*));
+E int FDECL(nasty, (struct monst*,BOOLEAN_P));
 E void NDECL(resurrect);
 E void NDECL(intervene);
@@ -2373,5 +2436,5 @@
 E void FDECL(buzz, (int,int,XCHAR_P,XCHAR_P,int,int));
 E void FDECL(melt_ice, (XCHAR_P,XCHAR_P));
-E int FDECL(zap_over_floor, (XCHAR_P,XCHAR_P,int,boolean *));
+E int FDECL(zap_over_floor, (XCHAR_P,XCHAR_P,int,boolean *,boolean));
 E void FDECL(fracture_rock, (struct obj *));
 E boolean FDECL(break_statue, (struct obj *));
@@ -2380,4 +2443,7 @@
 E int FDECL(resist, (struct monst *,CHAR_P,int,int));
 E void NDECL(makewish);
+E void FDECL(monstseesu,(unsigned long));
+E void FDECL(monstseesulose,(unsigned long));
+E void NDECL(blindingflash);
 
 #endif /* !MAKEDEFS_C && !LEV_LEX_C */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/flag.h nethack/include/flag.h
--- nh_orig/include/flag.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/flag.h	2009-09-07 11:23:57.340292818 -0400
@@ -184,4 +184,10 @@
 	boolean  extmenu;	/* extended commands use menu interface */
 #endif
+#ifdef MENU_COLOR
+	boolean use_menu_color;	/* use color in menus; only if wc_color */
+#endif
+#if defined(STATUS_COLORS) && defined(TEXTCOLOR)
+	boolean use_status_colors; /* use color in status line; only if wc_color */
+#endif
 #ifdef MFLOPPY
 	boolean  checkspace;	/* check disk space before writing files */
@@ -217,4 +223,7 @@
 	boolean lan_mail_fetched; /* mail is awaiting display */
 #endif
+#ifdef SORTLOOT
+	char sortloot;          /* sort items to loot alphabetically */
+#endif
 /*
  * Window capability support.
@@ -271,4 +280,7 @@
 	boolean  showrace;	/* show hero glyph by race rather than by role */
 	boolean  travelcmd;	/* allow travel command */
+	boolean  show_dgn_name; /* show dungeon names instead of Dlvl: on bottom line
+										 probably only good for people taking advantage of 
+										 the wide terminals allowed in Spork */
 	int	 runmode;	/* update screen display during run moves */
 #ifdef AUTOPICKUP_EXCEPTIONS
@@ -281,4 +293,7 @@
 	char	 altkeyhandler[MAX_ALTKEYHANDLER];
 #endif
+#ifdef REALTIME_ON_BOTL
+  boolean  showrealtime; /* show actual elapsed time */
+#endif
 };
 
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/global.h nethack/include/global.h
--- nh_orig/include/global.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/global.h	2009-09-07 09:52:23.773293399 -0400
@@ -237,4 +237,8 @@
 #endif
 
+#ifdef OSX
+# define MENU_COLOR_REGEX_POSIX
+#endif
+
 #ifdef VMS
 /* vms_exit() (sys/vms/vmsmisc.c) expects the non-VMS EXIT_xxx values below.
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/hack.h nethack/include/hack.h
--- nh_orig/include/hack.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/hack.h	2009-08-02 13:49:33.029408334 -0400
@@ -19,5 +19,5 @@
 #define ON		1
 #define OFF		0
-#define BOLT_LIM	8 /* from this distance ranged attacks will be made */
+#define BOLT_LIM	16 /* from this distance ranged attacks may be made */
 #define MAX_CARR_CAP	1000	/* so that boulders can be heavier */
 #define DUMMY { 0 }
@@ -100,7 +100,8 @@
 #define FLASHED_LIGHT	3
 #define INVIS_BEAM	4
-
 #define MATCH_WARN_OF_MON(mon)	 (Warn_of_mon && flags.warntype && \
-		   		 (flags.warntype & (mon)->data->mflags2))
+		   		 ((flags.warntype == (unsigned long)(mon)->data->mlet) || \
+						(flags.warntype == S_WERE && (mon)->data->mflags2 & M2_WERE) || \
+					   (flags.warntype == S_UNDEAD && (mon)->data->mflags2 & M2_UNDEAD)))
 
 #include "trap.h"
@@ -142,4 +143,5 @@
 #define MM_IGNOREWATER	  0x80	/* ignore water when positioning */
 #define MM_ADJACENTOK	  0x100 /* it is acceptable to use adjacent coordinates */
+#define MM_UNSAFEOK		  0x200 /* potentially dangerous locations (lava) are OK */
 
 /* special mhpmax value when loading bones monster to flag as extinct or genocided */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/mkroom.h nethack/include/mkroom.h
--- nh_orig/include/mkroom.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/mkroom.h	2009-12-03 16:14:46.415273207 -0500
@@ -12,4 +12,5 @@
 	schar rtype;		/* type of room (zoo, throne, etc...) */
 	schar rlit;		/* is the room lit ? */
+	schar needfill;		/* does the room need filling? */
 	schar doorct;		/* door count */
 	schar fdoor;		/* index for the first door of the room */
@@ -62,17 +63,19 @@
 #define COCKNEST	12	/* cockatrice nest (Tom Proudfoot) */
 #define ANTHOLE		13	/* ants (Tom Proudfoot) */
-#define SHOPBASE	14	/* everything above this is a shop */
-#define ARMORSHOP	15	/* specific shop defines for level compiler */
-#define SCROLLSHOP	16
-#define POTIONSHOP	17
-#define WEAPONSHOP	18
-#define FOODSHOP	19
-#define RINGSHOP	20
-#define WANDSHOP	21
-#define TOOLSHOP	22
-#define BOOKSHOP	23
-#define UNIQUESHOP	24	/* shops here & above not randomly gen'd. */
-#define CANDLESHOP	24
-#define MAXRTYPE	24	/* maximum valid room type */
+#define TRAPROOM	14
+#define POOLROOM	15
+#define SHOPBASE	16	/* everything above this is a shop */
+#define ARMORSHOP	17	/* specific shop defines for level compiler */
+#define SCROLLSHOP	18
+#define POTIONSHOP	19
+#define WEAPONSHOP	20
+#define FOODSHOP	21
+#define RINGSHOP	22
+#define WANDSHOP	23
+#define TOOLSHOP	24
+#define BOOKSHOP	25
+#define UNIQUESHOP	26	/* shops here & above not randomly gen'd. */
+#define CANDLESHOP	26
+#define MAXRTYPE	26	/* maximum valid room type */
 
 /* Special type for search_special() */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/monattk.h nethack/include/monattk.h
--- nh_orig/include/monattk.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/monattk.h	2009-08-02 13:49:33.032408767 -0400
@@ -25,4 +25,5 @@
 #define AT_GAZE		15	/* gaze - ranged */
 #define AT_TENT		16	/* tentacles */
+#define AT_SCRE	   17 /* scream - sonic attack */
 
 #define AT_WEAP		254	/* uses weapon */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/mondata.h nethack/include/mondata.h
--- nh_orig/include/mondata.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/mondata.h	2009-08-02 13:49:33.013408496 -0400
@@ -19,4 +19,6 @@
 #define resists_acid(mon)	(((mon)->mintrinsics & MR_ACID) != 0)
 #define resists_ston(mon)	(((mon)->mintrinsics & MR_STONE) != 0)
+#define resists_sick(mon)  ((mon)->data->mlet == S_FUNGUS || \
+										(mon)->data == &mons[PM_GHOUL])
 
 #define is_lminion(mon)		(is_minion((mon)->data) && \
@@ -27,4 +29,5 @@
 #define is_flyer(ptr)		(((ptr)->mflags1 & M1_FLY) != 0L)
 #define is_floater(ptr)		((ptr)->mlet == S_EYE)
+#define is_flying(mon)		((mon)->mflying != 0L)
 #define is_clinger(ptr)		(((ptr)->mflags1 & M1_CLING) != 0L)
 #define is_swimmer(ptr)		(((ptr)->mflags1 & M1_SWIM) != 0L)
@@ -128,4 +131,8 @@
 				 ((ptr) == &mons[PM_LONG_WORM_TAIL]))
 #define is_covetous(ptr)	((ptr->mflags3 & M3_COVETOUS))
+#define is_skittish(ptr)   ((ptr->mflags3 & M3_SKITTISH))
+#define is_accurate(ptr)   ((ptr->mflags3 & M3_EAGLEEYE))
+#define is_berserker(ptr)  ((ptr->mflags3 & M3_BERSERK))
+#define is_shopguard(ptr)  ((ptr->mflags3 & M3_SHOPGUARD))
 #define infravision(ptr)	((ptr->mflags3 & M3_INFRAVISION))
 #define infravisible(ptr)	((ptr->mflags3 & M3_INFRAVISIBLE))
@@ -147,4 +154,6 @@
 				  (ptr) == &mons[PM_FLAMING_SPHERE] || \
 				  (ptr) == &mons[PM_SHOCKING_SPHERE] || \
+				  (ptr) == &mons[PM_GOLD_DRAGON] || \
+				  (ptr) == &mons[PM_BABY_GOLD_DRAGON] || \
 				  (ptr) == &mons[PM_FIRE_VORTEX]) ? 1 : \
 				 ((ptr) == &mons[PM_FIRE_ELEMENTAL]) ? 1 : 0)
@@ -189,5 +198,10 @@
 
 #define befriend_with_obj(ptr, obj) ((obj)->oclass == FOOD_CLASS && \
-				     is_domestic(ptr))
+				(is_domestic(ptr) || (Role_if(PM_CAVEMAN) && (ptr) == &mons[PM_MASTODON]) || \
+				 ((obj)->otyp == BANANA && ((ptr) == &mons[PM_MONKEY] || (ptr) == &mons[PM_APE]))))
+
+#define is_rockbreaker(ptr)							\
+				(((ptr)->msound == MS_LEADER || is_rider((ptr))) && \
+				 !mtmp->mpeaceful)
 
 #endif /* MONDATA_H */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/monflag.h nethack/include/monflag.h
--- nh_orig/include/monflag.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/monflag.h	2009-08-02 13:49:33.023408895 -0400
@@ -153,11 +153,19 @@
 #define M3_WAITFORU	0x0040		/* waits to see you or get attacked */
 #define M3_CLOSE	0x0080		/* lets you close unless attacked */
+/* Infravision is currently implemented for players only */
+#define M3_INFRAVISION	0x0100		/* has infravision */
+#define M3_INFRAVISIBLE 0x0200		/* visible by infravision */
+#define M3_SKITTISH  0x0400	   /* tends to stay a few squares away from you */
+#define M3_EAGLEEYE  0x0800		/* gets an accuracy bonus to hit */
+#define M3_BERSERK   0x1000	   /* extremely indiscriminate in its attacks */
+#define M3_SHOPGUARD	0x2000	   /* Guardian for a shop */
 
 #define M3_COVETOUS	0x001f		/* wants something */
 #define M3_WAITMASK	0x00c0		/* waiting... */
 
-/* Infravision is currently implemented for players only */
-#define M3_INFRAVISION	0x0100		/* has infravision */
-#define M3_INFRAVISIBLE 0x0200		/* visible by infravision */
+#define M4_VULNERABLE_FIRE		0x0001	 /* inherent elemental vulnerabilities */
+#define M4_VULNERABLE_COLD		0x0002
+#define M4_VULNERABLE_ELEC		0x0004
+#define M4_VULNERABLE_ACID		0x0008
 
 #define MZ_TINY		0		/* < 2' */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/monst.h nethack/include/monst.h
--- nh_orig/include/monst.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/monst.h	2009-09-07 11:18:19.719417264 -0400
@@ -41,5 +41,5 @@
 	struct monst *nmon;
 	struct permonst *data;
-	unsigned m_id;
+	size_t m_id;
 	short mnum;		/* permanent monster index number */
 	short movement;		/* movement points (derived from permonst definition and added effects */
@@ -64,4 +64,24 @@
 	int mspec_used;		/* monster's special ability attack timeout */
 
+/* These should stay in the same order as monattk.h so
+ * the mask translations will work properly */
+
+#define M_SEEN_NOTHING	0x0000
+#define M_SEEN_MAGR		0x0001
+#define M_SEEN_FIRE		0x0002
+#define M_SEEN_COLD		0x0004
+#define M_SEEN_SLEEP		0x0008
+#define M_SEEN_DISINT	0x0010
+#define M_SEEN_ELEC		0x0020
+#define M_SEEN_POISON	0x0040
+#define M_SEEN_ACID	 	0x0080
+#define M_SEEN_REFL		0x0100
+
+#define m_seenres(mon,mask)	((mon)->seen_resistance & (mask))
+#define m_setseen(mon,mask)	((mon)->seen_resistance |= (mask))
+#define m_sawlose(mon,mask)	((mon)->seen_resistance &= (~mask))
+
+	unsigned long seen_resistance;  /* Has seen you resist an element or magical effect */
+
 	Bitfield(female,1);	/* is female */
 	Bitfield(minvis,1);	/* currently invisible */
@@ -96,4 +116,5 @@
 	Bitfield(mcanmove,1);	/* paralysis, similar to mblinded */
 	Bitfield(mfrozen,7);
+	Bitfield(mflying,1);	  /* is monster levitating/flying artificially? */
 
 	Bitfield(msleeping,1);	/* asleep until woken */
@@ -103,7 +124,10 @@
 	Bitfield(mtrapped,1);	/* trapped in a pit, web or bear trap */
 	Bitfield(mleashed,1);	/* monster is on a leash */
+	Bitfield(mberserk,1);    /* monster is berserk */
+
 	Bitfield(isshk,1);	/* is shopkeeper */
 	Bitfield(isminion,1);	/* is a minion */
 
+	Bitfield(isshopguard,1);	 /* monster is a shop guard */
 	Bitfield(isgd,1);	/* is guard */
 	Bitfield(ispriest,1);	/* is a priest */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/monsym.h nethack/include/monsym.h
--- nh_orig/include/monsym.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/monsym.h	2009-08-02 13:49:33.040407823 -0400
@@ -74,4 +74,7 @@
 #define MAXMCLASSES 61	/* number of monster classes */
 
+#define S_WERE		100	/* don't include this in MAXMCLASSES, it's a hack for warning */
+#define S_UNDEAD	101	/* etc */
+
 #if 0	/* moved to decl.h so that makedefs.c won't see them */
 extern const char def_monsyms[MAXMCLASSES];	/* default class symbols */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/objclass.h nethack/include/objclass.h
--- nh_orig/include/objclass.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/objclass.h	2009-10-05 13:36:35.884293519 -0400
@@ -140,5 +140,6 @@
 #define CHAIN_CLASS	16
 #define VENOM_CLASS	17
-#define MAXOCLASSES	18
+#define FURNITURE_CLASS	18
+#define MAXOCLASSES	19
 
 #define ALLOW_COUNT	(MAXOCLASSES+1) /* Can be used in the object class */
@@ -148,4 +149,5 @@
 #define BURNING_OIL	(MAXOCLASSES+1) /* Can be used as input to explode. */
 #define MON_EXPLODE	(MAXOCLASSES+2) /* Exploding monster (e.g. gas spore) */
+#define MON_CASTBALL	(MAXOCLASSES+3) /* For monsters casting area-effect spells */
 
 #if 0	/* moved to decl.h so that makedefs.c won't see them */
@@ -173,4 +175,5 @@
 #define CHAIN_SYM	'_'
 #define VENOM_SYM	'.'
+#define FURNITURE_SYM	'\\'
 
 struct fruit {
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/obj.h nethack/include/obj.h
--- nh_orig/include/obj.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/obj.h	2009-10-22 09:37:11.099549062 -0400
@@ -23,5 +23,5 @@
 
 	struct obj *cobj;	/* contents list for containers */
-	unsigned o_id;
+	size_t o_id;
 	xchar ox,oy;
 	short otyp;		/* object class number */
@@ -98,6 +98,13 @@
 #define spestudied corpsenm	/* # of times a spellbook has been studied */
 #define fromsink  corpsenm	/* a potion from a sink */
+
+#ifdef RECORD_ACHIEVE
+#define record_achieve_special corpsenm
+#endif
+
 	unsigned oeaten;	/* nutrition left in food, if partly eaten */
 	long age;		/* creation date */
+	long capacity;	  /* how much can this container hold? */
+#define MAX_CAPACITY 0xFFFFFF	  /* "lots" */
 
 	uchar onamelth;		/* length of name (following oxlth) */
@@ -139,6 +146,5 @@
 #define is_pole(otmp)	((otmp->oclass == WEAPON_CLASS || \
 			otmp->oclass == TOOL_CLASS) && \
-			 (objects[otmp->otyp].oc_skill == P_POLEARMS || \
-			 objects[otmp->otyp].oc_skill == P_LANCE))
+			 (objects[otmp->otyp].oc_skill == P_POLEARMS))
 #define is_spear(otmp)	(otmp->oclass == WEAPON_CLASS && \
 			 objects[otmp->otyp].oc_skill >= P_SPEAR && \
@@ -158,4 +164,11 @@
 			 objects[otmp->otyp].oc_skill >= -P_BOOMERANG && \
 			 objects[otmp->otyp].oc_skill <= -P_DART)
+#define is_thrown(otmp)	  ((otmp->oclass == WEAPON_CLASS) && \
+		  ((objects[otmp->otyp].oc_skill >= P_DART && \
+			 objects[otmp->otyp].oc_skill <= P_BOOMERANG) || \
+			 objects[otmp->otyp].oc_skill == P_DAGGER || \
+			 objects[otmp->otyp].oc_skill == P_KNIFE || \
+			(objects[otmp->otyp].oc_skill >= P_SPEAR && \
+			 objects[otmp->otyp].oc_skill <= P_TRIDENT)))
 #define is_weptool(o)	((o)->oclass == TOOL_CLASS && \
 			 objects[(o)->otyp].oc_skill != P_NONE)
@@ -218,6 +231,7 @@
 #define Has_contents(o) (/* (Is_container(o) || (o)->otyp == STATUE) && */ \
 			 (o)->cobj != (struct obj *)0)
-#define Is_container(o) ((o)->otyp >= LARGE_BOX && (o)->otyp <= BAG_OF_TRICKS)
-#define Is_box(otmp)	(otmp->otyp == LARGE_BOX || otmp->otyp == CHEST)
+#define Is_container(o) ((o)->otyp >= LARGE_BOX && (o)->otyp <= BAG_OF_POO)
+#define Is_box(otmp)	(otmp->otyp == LARGE_BOX || otmp->otyp == CHEST || \
+								otmp->otyp == IRON_SAFE)
 #define Is_mbag(otmp)	(otmp->otyp == BAG_OF_HOLDING || \
 			 otmp->otyp == BAG_OF_TRICKS)
@@ -273,5 +287,6 @@
 				|| (otmp)->otyp == TALLOW_CANDLE\
 				|| (otmp)->otyp == WAX_CANDLE\
-				|| (otmp)->otyp == POT_OIL)
+				|| (otmp)->otyp == POT_OIL\
+				|| (otmp)->otyp == BAG_OF_POO)
 /* object can be ignited */
 #define ignitable(otmp)	((otmp)->otyp == BRASS_LANTERN\
@@ -280,11 +295,12 @@
 				|| (otmp)->otyp == TALLOW_CANDLE\
 				|| (otmp)->otyp == WAX_CANDLE\
-				|| (otmp)->otyp == POT_OIL)
+				|| (otmp)->otyp == POT_OIL\
+				|| (otmp)->otyp == FUR_BRAZIER\
+				|| (otmp)->otyp == BAG_OF_POO)
 
 /* special stones */
 #define is_graystone(obj)	((obj)->otyp == LUCKSTONE || \
-				 (obj)->otyp == LOADSTONE || \
-				 (obj)->otyp == FLINT     || \
-				 (obj)->otyp == TOUCHSTONE)
+				 (obj)->otyp == LOADSTONE || (obj)->otyp == FLINT     || \
+				 (obj)->otyp == TOUCHSTONE || (obj)->otyp == SALT_CHUNK)
 
 /* misc */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/patchlevel.h nethack/include/patchlevel.h
--- nh_orig/include/patchlevel.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/patchlevel.h	2009-10-22 15:16:02.350272918 -0400
@@ -3,11 +3,11 @@
 /* NetHack may be freely redistributed.  See license for details. */
 
-/* NetHack 3.4.3 */
-#define VERSION_MAJOR	3
-#define VERSION_MINOR	4
+/* SporkHack 0.3.0 */
+#define VERSION_MAJOR	0
+#define VERSION_MINOR	6
 /*
  * PATCHLEVEL is updated for each release.
  */
-#define PATCHLEVEL	3
+#define PATCHLEVEL	2
 /*
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
@@ -17,8 +17,8 @@
 
 #define COPYRIGHT_BANNER_A \
-"NetHack, Copyright 1985-2003"
+"SporkHack, copyright 2007 Derek S. Ray; a variant of NetHack 3.4.3, "
 
 #define COPYRIGHT_BANNER_B \
-"         By Stichting Mathematisch Centrum and M. Stephenson."
+"  copyright 1985-2003 by Stichting Mathematisch Centrum and M. Stephenson."
 
 #define COPYRIGHT_BANNER_C \
@@ -34,5 +34,7 @@
  * with all four numbers specified as two hexadecimal digits.
  */
-#define VERSION_COMPATIBILITY 0x03040000L	/* 3.4.0-0 */
+
+/*                            0xMMmmPPeeL            */
+#define VERSION_COMPATIBILITY 0x00060200L	/* 0.6.1-0 */
 
 
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/permonst.h nethack/include/permonst.h
--- nh_orig/include/permonst.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/permonst.h	2009-09-13 08:38:18.966292366 -0400
@@ -56,7 +56,8 @@
 	uchar		mresists;		/* resistances */
 	uchar		mconveys;		/* conveyed by eating */
-	unsigned long	mflags1,		/* boolean bitflags */
-			mflags2;		/* more boolean bitflags */
-	unsigned short	mflags3;		/* yet more boolean bitflags */
+	unsigned long	mflags1;		/* boolean bitflags */
+	unsigned long  mflags2;		/* more boolean bitflags */
+	unsigned long	mflags3;		/* yet more boolean bitflags */
+	unsigned long	mflags4;	  /* Add room for more */
 # ifdef TEXTCOLOR
 	uchar		mcolor;			/* color to use */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/prop.h nethack/include/prop.h
--- nh_orig/include/prop.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/prop.h	2009-09-05 10:47:01.555291838 -0400
@@ -74,5 +74,14 @@
 #define WARN_OF_MON		65
 #define DETECT_MONSTERS		66
-#define LAST_PROP		(DETECT_MONSTERS)
+#define WERE_RES			67
+#define BLIND_RES			68
+#define SLOW				69
+#define VISION				70
+#define LUCKY				71
+#define VULN_FIRE			72
+#define VULN_COLD			73
+#define VULN_ELEC			74
+#define VULN_ACID			75
+#define LAST_PROP		 	(VULN_ACID)
 
 /*** Where the properties come from ***/
@@ -100,4 +109,5 @@
 #	define W_ART	    0x00001000L /* Carrying artifact (not really worn) */
 #	define W_ARTI	    0x00002000L /* Invoked artifact  (not really worn) */
+#  define W_LAUNCHER  0x00004000L /* Selected ranged launcher */
 	/* Amulets, rings, tools, and other items */
 #	define W_AMUL	    0x00010000L /* Amulet */
@@ -123,5 +133,6 @@
 #	define FROMRACE     0x02000000L /* Gain/lose with experience, for race */
 #	define FROMOUTSIDE  0x04000000L /* By corpses, prayer, thrones, etc. */
-#	define INTRINSIC    (FROMOUTSIDE|FROMRACE|FROMEXPER)
+#  define HAVEPARTIAL  0x08000000L /* This is no longer a timeout, but a partial resistance */
+#	define INTRINSIC    (FROMOUTSIDE|FROMRACE|FROMEXPER|HAVEPARTIAL)
 	/* Control flags */
 #	define I_SPECIAL    0x10000000L /* Property is controllable */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/rm.h nethack/include/rm.h
--- nh_orig/include/rm.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/rm.h	2009-10-05 13:36:35.884293519 -0400
@@ -59,14 +59,13 @@
 #define LADDER		26
 #define FOUNTAIN	27
-#define THRONE		28
-#define SINK		29
-#define GRAVE		30
-#define ALTAR		31
-#define ICE		32
-#define DRAWBRIDGE_DOWN 33
-#define AIR		34
-#define CLOUD		35
+#define SINK		28
+#define GRAVE		29
+#define ALTAR		30
+#define ICE		31
+#define DRAWBRIDGE_DOWN 32
+#define AIR		33
+#define CLOUD		34
 
-#define MAX_TYPE	36
+#define MAX_TYPE	35
 #define INVALID_TYPE	127
 
@@ -87,5 +86,4 @@
 #define SPACE_POS(typ)	((typ) > DOOR)
 #define IS_POOL(typ)	((typ) >= POOL && (typ) <= DRAWBRIDGE_UP)
-#define IS_THRONE(typ)	((typ) == THRONE)
 #define IS_FOUNTAIN(typ) ((typ) == FOUNTAIN)
 #define IS_SINK(typ)	((typ) == SINK)
@@ -133,84 +131,86 @@
 #define S_altar		26
 #define S_grave		27
-#define S_throne	28
-#define S_sink		29
-#define S_fountain	30
-#define S_pool		31
-#define S_ice		32
-#define S_lava		33
-#define S_vodbridge	34
-#define S_hodbridge	35
-#define S_vcdbridge	36	/* closed drawbridge, vertical wall */
-#define S_hcdbridge	37	/* closed drawbridge, horizontal wall */
-#define S_air		38
-#define S_cloud		39
-#define S_water		40
+#define S_sink		28
+#define S_fountain	29
+#define S_pool		30
+#define S_ice		31
+#define S_lava		32
+#define S_vodbridge	33
+#define S_hodbridge	34
+#define S_vcdbridge	35	/* closed drawbridge, vertical wall */
+#define S_hcdbridge	36	/* closed drawbridge, horizontal wall */
+#define S_air		37
+#define S_cloud		38
+#define S_water		39
 
 /* end dungeon characters, begin traps */
 
-#define S_arrow_trap		41
-#define S_dart_trap		42
-#define S_falling_rock_trap	43
-#define S_squeaky_board		44
-#define S_bear_trap		45
-#define S_land_mine		46
-#define S_rolling_boulder_trap	47
-#define S_sleeping_gas_trap	48
-#define S_rust_trap		49
-#define S_fire_trap		50
-#define S_pit			51
-#define S_spiked_pit		52
-#define S_hole			53
-#define S_trap_door		54
-#define S_teleportation_trap	55
-#define S_level_teleporter	56
-#define S_magic_portal		57
-#define S_web			58
-#define S_statue_trap		59
-#define S_magic_trap		60
-#define S_anti_magic_trap	61
-#define S_polymorph_trap	62
+#define S_arrow_trap		40
+#define S_dart_trap		41
+#define S_falling_rock_trap	42
+#define S_squeaky_board		43
+#define S_bear_trap		44
+#define S_land_mine		45
+#define S_rolling_boulder_trap	46
+#define S_sleeping_gas_trap	47
+#define S_rust_trap		48
+#define S_fire_trap		49
+#define S_pit			50
+#define S_spiked_pit		51
+#define S_hole			52
+#define S_trap_door		53
+#define S_teleportation_trap	54
+#define S_level_teleporter	55
+#define S_magic_portal		56
+#define S_web			57
+#define S_statue_trap		58
+#define S_magic_trap		59
+#define S_anti_magic_trap	60
+#define S_polymorph_trap	61
+#define S_spear_trap		62
+#define S_falling_rocks_trap	63
+#define S_magic_beam_trap	64
 
 /* end traps, begin special effects */
 
-#define S_vbeam		63	/* The 4 zap beam symbols.  Do NOT separate. */
-#define S_hbeam		64	/* To change order or add, see function     */
-#define S_lslant	65	/* zapdir_to_glyph() in display.c.	    */
-#define S_rslant	66
-#define S_digbeam	67	/* dig beam symbol */
-#define S_flashbeam	68	/* camera flash symbol */
-#define S_boomleft	69	/* thrown boomerang, open left, e.g ')'    */
-#define S_boomright	70	/* thrown boomerand, open right, e.g. '('  */
-#define S_ss1		71	/* 4 magic shield glyphs */
-#define S_ss2		72
-#define S_ss3		73
-#define S_ss4		74
+#define S_vbeam		65	/* The 4 zap beam symbols.  Do NOT separate. */
+#define S_hbeam		66	/* To change order or add, see function     */
+#define S_lslant	67	/* zapdir_to_glyph() in display.c.	    */
+#define S_rslant	68
+#define S_digbeam	69	/* dig beam symbol */
+#define S_flashbeam	70	/* camera flash symbol */
+#define S_boomleft	71	/* thrown boomerang, open left, e.g ')'    */
+#define S_boomright	72	/* thrown boomerand, open right, e.g. '('  */
+#define S_ss1		73	/* 4 magic shield glyphs */
+#define S_ss2		74
+#define S_ss3		75
+#define S_ss4		76
 
 /* The 8 swallow symbols.  Do NOT separate.  To change order or add, see */
 /* the function swallow_to_glyph() in display.c.			 */
-#define S_sw_tl		75	/* swallow top left [1]			*/
-#define S_sw_tc		76	/* swallow top center [2]	Order:	*/
-#define S_sw_tr		77	/* swallow top right [3]		*/
-#define S_sw_ml		78	/* swallow middle left [4]	1 2 3	*/
-#define S_sw_mr		79	/* swallow middle right [6]	4 5 6	*/
-#define S_sw_bl		80	/* swallow bottom left [7]	7 8 9	*/
-#define S_sw_bc		81	/* swallow bottom center [8]		*/
-#define S_sw_br		82	/* swallow bottom right [9]		*/
+#define S_sw_tl		77	/* swallow top left [1]			*/
+#define S_sw_tc		78	/* swallow top center [2]	Order:	*/
+#define S_sw_tr		79	/* swallow top right [3]		*/
+#define S_sw_ml		80	/* swallow middle left [4]	1 2 3	*/
+#define S_sw_mr		81	/* swallow middle right [6]	4 5 6	*/
+#define S_sw_bl		82	/* swallow bottom left [7]	7 8 9	*/
+#define S_sw_bc		83	/* swallow bottom center [8]		*/
+#define S_sw_br		84	/* swallow bottom right [9]		*/
 
-#define S_explode1	83	/* explosion top left			*/
-#define S_explode2	84	/* explosion top center			*/
-#define S_explode3	85	/* explosion top right		 Ex.	*/
-#define S_explode4	86	/* explosion middle left		*/
-#define S_explode5	87	/* explosion middle center	 /-\	*/
-#define S_explode6	88	/* explosion middle right	 |@|	*/
-#define S_explode7	89	/* explosion bottom left	 \-/	*/
-#define S_explode8	90	/* explosion bottom center		*/
-#define S_explode9	91	/* explosion bottom right		*/
+#define S_explode1	85	/* explosion top left			*/
+#define S_explode2	86	/* explosion top center			*/
+#define S_explode3	87	/* explosion top right		 Ex.	*/
+#define S_explode4	88	/* explosion middle left		*/
+#define S_explode5	89	/* explosion middle center	 /-\	*/
+#define S_explode6	90	/* explosion middle right	 |@|	*/
+#define S_explode7	91	/* explosion bottom left	 \-/	*/
+#define S_explode8	92	/* explosion bottom center		*/
+#define S_explode9	93	/* explosion bottom right		*/
 
 /* end effects */
 
-#define MAXPCHARS	92	/* maximum number of mapped characters */
-#define MAXDCHARS	41	/* maximum of mapped dungeon characters */
-#define MAXTCHARS	22	/* maximum of mapped trap characters */
+#define MAXPCHARS	94	/* maximum number of mapped characters */
+#define MAXDCHARS	40	/* maximum of mapped dungeon characters */
+#define MAXTCHARS	25	/* maximum of mapped trap characters */
 #define MAXECHARS	29	/* maximum of mapped effects characters */
 #define MAXEXPCHARS	9	/* number of explosion characters */
@@ -253,9 +253,4 @@
 
 /*
- * Thrones should only be looted once.
- */
-#define T_LOOTED	1
-
-/*
  * Trees have more than one kick result.
  */
@@ -463,7 +458,39 @@
 	Bitfield(graveyard,1);		/* has_morgue, but remains set */
 	Bitfield(is_maze_lev,1);
+	Bitfield(stormy,1);		/* thunderous clouds */
 
 	Bitfield(is_cavernous_lev,1);
 	Bitfield(arboreal, 1);		/* Trees replace rock */
+	/* and where it is written "ad aquarium"... */
+	Bitfield(vault_is_aquarium,1);
+};
+
+struct mon_gen_tuple {
+    int freq;
+    boolean is_sym;
+    int monid;
+    struct mon_gen_tuple *next;
+};
+
+struct mon_gen_override {
+    int override_chance;
+    int total_mon_freq;
+    struct mon_gen_tuple *gen_chances;
+};
+
+#define LVLSND_HEARD	0	/* You_hear(msg); */
+#define LVLSND_PLINED	1	/* pline(msg); */
+#define LVLSND_VERBAL	2	/* verbalize(msg); */
+#define LVLSND_FELT	3	/* You_feel(msg); */
+
+struct lvl_sound_bite {
+    int flags; /* LVLSND_foo */
+    char *msg;
+};
+
+struct lvl_sounds {
+    int freq;
+    int n_sounds;
+    struct lvl_sound_bite *sounds;
 };
 
@@ -485,4 +512,6 @@
     struct damage	*damagelist;
     struct levelflags	flags;
+    struct mon_gen_override *mon_gen;
+    struct lvl_sounds	*sounds;
 }
 dlevel_t;
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/sp_lev.h nethack/include/sp_lev.h
--- nh_orig/include/sp_lev.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/sp_lev.h	2009-12-03 16:14:46.415273207 -0500
@@ -18,13 +18,202 @@
 
     /* Per level flags */
-#define NOTELEPORT	1
-#define HARDFLOOR	2
-#define NOMMAP		4
-#define SHORTSIGHTED	8
-#define ARBOREAL	16
+#define NOTELEPORT	0x00000001L
+#define HARDFLOOR	0x00000002L
+#define NOMMAP		0x00000004L
+#define SHORTSIGHTED	0x00000008L
+#define ARBOREAL	0x00000010L
+#define NOFLIPX		0x00000020L
+#define NOFLIPY		0x00000040L
+#define MAZELEVEL	0x00000080L
+#define PREMAPPED	0x00000100L
+#define SHROUD		0x00000200L
+#define STORMY		0x00000400L
+#define GRAVEYARD	0x00000800L
 
-    /* special level types */
-#define SP_LEV_ROOMS	1
-#define SP_LEV_MAZE	2
+/* different level layout initializers */
+#define LVLINIT_NONE		0
+#define LVLINIT_SOLIDFILL	1
+#define LVLINIT_MAZEGRID	2
+#define LVLINIT_MINES		3
+
+/* max. layers of object containment */
+#define MAX_CONTAINMENT 10
+
+/* max. # of random registers */
+#define MAX_REGISTERS	10
+
+/* max. nested depth of subrooms */
+#define MAX_NESTED_ROOMS 5
+
+/* max. # of opcodes per special level */
+#define SPCODER_MAX_RUNTIME	65536
+
+/* Opcodes for creating the level
+ * If you change these, also change opcodestr[] in util/lev_main.c
+ */
+enum opcode_defs {
+    SPO_NULL = 0,
+    SPO_MESSAGE,
+    SPO_MONSTER,
+    SPO_OBJECT,
+    SPO_ENGRAVING,
+    SPO_ROOM,
+    SPO_SUBROOM,
+    SPO_DOOR,
+    SPO_STAIR,
+    SPO_LADDER,
+    SPO_ALTAR,
+    SPO_FOUNTAIN,
+    SPO_SINK,
+    SPO_POOL,
+    SPO_TRAP,
+    SPO_GOLD,
+    SPO_CORRIDOR,
+    SPO_LEVREGION,
+    SPO_RANDOM_OBJECTS,
+    SPO_RANDOM_PLACES,
+    SPO_RANDOM_MONSTERS,
+    SPO_DRAWBRIDGE,
+    SPO_MAZEWALK,
+    SPO_NON_DIGGABLE,
+    SPO_NON_PASSWALL,
+    SPO_WALLIFY,
+    SPO_MAP,
+    SPO_ROOM_DOOR,
+    SPO_REGION,
+    SPO_CMP,
+    SPO_JMP,
+    SPO_JL,
+    SPO_JLE,
+    SPO_JG,
+    SPO_JGE,
+    SPO_JE,
+    SPO_JNE,
+    SPO_SPILL,
+    SPO_TERRAIN,
+    SPO_REPLACETERRAIN,
+    SPO_EXIT,
+    SPO_ENDROOM,
+    SPO_RANDLINE,
+    SPO_POP_CONTAINER,
+    SPO_PUSH,
+    SPO_POP,
+    SPO_RN2,
+    SPO_DEC,
+    SPO_COPY,
+    SPO_MON_GENERATION,
+    SPO_END_MONINVENT,
+    SPO_GRAVE,
+    SPO_FRAME_PUSH,
+    SPO_FRAME_POP,
+    SPO_CALL,
+    SPO_RETURN,
+    SPO_INITLEVEL,
+    SPO_LEVEL_FLAGS,
+    SPO_LEVEL_SOUNDS,
+    SPO_WALLWALK,
+
+    MAX_SP_OPCODES
+};
+
+/* MONSTER and OBJECT can take a variable number of parameters,
+ * they also pop different # of values from the stack. So,
+ * first we pop a value that tells what the _next_ value will
+ * mean.
+ */
+/* MONSTER */
+#define SP_M_V_PEACEFUL         0
+#define SP_M_V_ALIGN            1
+#define SP_M_V_ASLEEP           2
+#define SP_M_V_APPEAR           3
+#define SP_M_V_NAME             4
+
+#define SP_M_V_FEMALE		5
+#define SP_M_V_INVIS		6
+#define SP_M_V_CANCELLED	7
+#define SP_M_V_REVIVED		8
+#define SP_M_V_AVENGE		9
+#define SP_M_V_FLEEING		10
+#define SP_M_V_BLINDED		11
+#define SP_M_V_PARALYZED	12
+#define SP_M_V_STUNNED		13
+#define SP_M_V_CONFUSED		14
+#define SP_M_V_SEENTRAPS	15
+
+#define SP_M_V_END              16 /* end of variable parameters */
+
+/* OBJECT */
+#define SP_O_V_SPE              0
+#define SP_O_V_CURSE            1
+#define SP_O_V_CORPSENM         2
+#define SP_O_V_NAME             3
+#define SP_O_V_QUAN		4
+#define SP_O_V_BURIED		5
+#define SP_O_V_LIT		6
+#define SP_O_V_ERODED		7
+#define SP_O_V_LOCKED		8
+#define SP_O_V_TRAPPED		9
+#define SP_O_V_RECHARGED	10
+#define SP_O_V_INVIS		11
+#define SP_O_V_GREASED		12
+#define SP_O_V_BROKEN		13
+#define SP_O_V_END              14 /* end of variable parameters */
+
+
+/* When creating objects, we need to know whether
+ * it's a container and/or contents.
+ */
+#define SP_OBJ_CONTENT		0x1
+#define SP_OBJ_CONTAINER	0x2
+
+
+
+#define SPOVAR_NULL	0
+#define SPOVAR_INT	1 /* l */
+#define SPOVAR_STRING	2 /* str */
+
+struct opvar {
+    xchar spovartyp; /* one of SPOVAR_foo */
+    union {
+	char *str;
+	long l;
+    } vardata;
+};
+
+struct splevstack {
+    long depth;
+    long depth_alloc;
+    struct opvar **stackdata;
+};
+
+
+struct sp_frame {
+    struct sp_frame *next;
+    struct splevstack *stack;
+    long n_opcode;
+};
+
+
+struct sp_coder {
+    struct splevstack *stack;
+    struct sp_frame *frame;
+    int allow_flips;
+    int premapped;
+    struct mkroom *croom;
+    struct mkroom *tmproomlist[MAX_NESTED_ROOMS+1];
+    boolean failed_room[MAX_NESTED_ROOMS+1];
+    int n_subroom;
+    boolean exit_script;
+    int  lvl_is_joined;
+
+    int opcode;  /* current opcode */
+    struct opvar *opdat; /* current push data (req. opcode == SPO_PUSH) */
+};
+
+/* special level coder CPU flags */
+#define SP_CPUFLAG_LT	1
+#define SP_CPUFLAG_GT	2
+#define SP_CPUFLAG_EQ	4
+#define SP_CPUFLAG_ZERO	8
 
 /*
@@ -32,4 +221,20 @@
  */
 
+typedef struct {
+    xchar x1,y1,x2,y2;
+    xchar fg, lit;
+    int roughness;
+    xchar thick;
+} randline;
+
+typedef struct {
+	int cmp_what;
+	int cmp_val;
+} opcmp;
+
+typedef struct {
+	long jmp_target;
+} opjmp;
+
 typedef union str_or_len {
 	char *str;
@@ -38,8 +243,10 @@
 
 typedef struct {
-	boolean init_present, padding;
+	xchar   init_style; /* one of LVLINIT_foo */
 	char	fg, bg;
 	boolean smoothed, joined;
 	xchar	lit, walled;
+	long	flags;
+	schar	filling;
 } lev_init;
 
@@ -53,5 +260,5 @@
 
 typedef struct {
-	xchar x, y, chance, type;
+	xchar x, y, type;
 } trap;
 
@@ -60,6 +267,9 @@
 	short id;
 	aligntyp align;
-	xchar x, y, chance, class, appear;
+	xchar x, y, class, appear;
 	schar peaceful, asleep;
+        short female, invis, cancelled, revived, avenge, fleeing, blinded, paralyzed, stunned, confused;
+        long seentraps;
+	short has_invent;
 } monster;
 
@@ -68,6 +278,10 @@
 	int   corpsenm;
 	short id, spe;
-	xchar x, y, chance, class, containment;
+	xchar x, y, class, containment;
 	schar curse_state;
+	int   quan;
+	short buried;
+	short lit;
+        short eroded, locked, trapped, recharged, invis, greased, broken;
 } object;
 
@@ -83,5 +297,5 @@
 
 typedef struct {
-	xchar x, y, dir;
+    xchar x, y, dir, stocked, typ;
 } walk;
 
@@ -103,4 +317,16 @@
 } region;
 
+typedef struct {
+    xchar areatyp;
+    xchar x1,y1,x2,y2;
+    xchar ter, tlit;
+} terrain;
+
+typedef struct {
+    xchar chance;
+    xchar x1,y1,x2,y2;
+    xchar fromter, toter, tolit;
+} replaceterrain;
+
 /* values for rtype are defined in dungeon.h */
 typedef struct {
@@ -135,92 +361,21 @@
 } pool;
 
-typedef struct {
-	char halign, valign;
-	char xsize, ysize;
-	char **map;
-	char nrobjects;
-	char *robjects;
-	char nloc;
-	char *rloc_x;
-	char *rloc_y;
-	char nrmonst;
-	char *rmonst;
-	char nreg;
-	region **regions;
-	char nlreg;
-	lev_region **lregions;
-	char ndoor;
-	door **doors;
-	char ntrap;
-	trap **traps;
-	char nmonster;
-	monster **monsters;
-	char nobject;
-	object **objects;
-	char ndrawbridge;
-	drawbridge **drawbridges;
-	char nwalk;
-	walk **walks;
-	char ndig;
-	digpos **digs;
-	char npass;
-	digpos **passs;
-	char nlad;
-	lad **lads;
-	char nstair;
-	stair **stairs;
-	char naltar;
-	altar **altars;
-	char ngold;
-	gold **golds;
-	char nengraving;
-	engraving **engravings;
-	char nfountain;
-	fountain **fountains;
-} mazepart;
-
-typedef struct {
-	long flags;
-	lev_init init_lev;
-	schar filling;
-	char numpart;
-	mazepart **parts;
-} specialmaze;
-
 typedef struct _room {
-	char  *name;
-	char  *parent;
+	Str_or_Len name;
+	Str_or_Len parent;
 	xchar x, y, w, h;
 	xchar xalign, yalign;
 	xchar rtype, chance, rlit, filled;
-	char ndoor;
-	room_door **doors;
-	char ntrap;
-	trap **traps;
-	char nmonster;
-	monster **monsters;
-	char nobject;
-	object **objects;
-	char naltar;
-	altar **altars;
-	char nstair;
-	stair **stairs;
-	char ngold;
-	gold **golds;
-	char nengraving;
-	engraving **engravings;
-	char nfountain;
-	fountain **fountains;
-	char nsink;
-	sink **sinks;
-	char npool;
-	pool **pools;
-	/* These three fields are only used when loading the level... */
-	int nsubroom;
-	struct _room *subrooms[MAX_SUBROOMS];
-	struct mkroom *mkr;
 } room;
 
 typedef struct {
+    	schar zaligntyp;
+	schar keep_region;
+	schar halign, valign;
+	char xsize, ysize;
+	char **map;
+} mazepart;
+
+typedef struct {
 	struct {
 		xchar room;
@@ -230,17 +385,29 @@
 } corridor;
 
-/* used only by lev_comp */
 typedef struct {
-	long flags;
-	lev_init init_lev;
-	char nrobjects;
-	char *robjects;
-	char nrmonst;
-	char *rmonst;
-	xchar nroom;
-	room **rooms;
-	xchar ncorr;
-	corridor **corrs;
-} splev;
+    int opcode;
+    struct opvar *opdat;
+} _opcode;
+
+typedef struct {
+    _opcode  *opcodes;
+    long     n_opcodes;
+} sp_lev;
+
+typedef struct {
+	xchar x, y, direction, count, lit;
+	char typ;
+} spill;
+
+
+/* only used by lev_comp */
+
+struct lc_funcdefs {
+    struct lc_funcdefs *next;
+    char *name;
+    long addr;
+    sp_lev code;
+    long n_called;
+};
 
 #endif /* SP_LEV_H */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/system.h nethack/include/system.h
--- nh_orig/include/system.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/system.h	2009-09-07 09:52:30.877293621 -0400
@@ -474,5 +474,5 @@
 #ifdef NEED_VARARGS
 # if defined(USE_STDARG) || defined(USE_VARARGS)
-#  if !defined(SVR4) && !defined(apollo)
+#  if !defined(SVR4) && !defined(apollo) && !defined(OSX)
 #   if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
 #    if !(defined(SUNOS4) && defined(__STDC__)) /* Solaris unbundled cc (acc) */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/trap.h nethack/include/trap.h
--- nh_orig/include/trap.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/trap.h	2009-09-28 07:52:26.134418460 -0400
@@ -73,5 +73,8 @@
 #define ANTI_MAGIC	21
 #define POLY_TRAP	22
-#define TRAPNUM 23
+#define SPEAR_TRAP 23
+#define COLLAPSE_TRAP 24
+#define MAGIC_BEAM_TRAP	25
+#define TRAPNUM 26
 
 #endif /* TRAP_H */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/unixconf.h nethack/include/unixconf.h
--- nh_orig/include/unixconf.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/unixconf.h	2009-08-02 13:49:33.035408669 -0400
@@ -33,10 +33,11 @@
 
 /* define any of the following that are appropriate */
-#define SVR4		/* use in addition to SYSV for System V Release 4 */
+/* #define SVR4		/* use in addition to SYSV for System V Release 4 */
 			/* including Solaris 2+ */
 #define NETWORK		/* if running on a networked system */
 			/* e.g. Suns sharing a playground through NFS */
 /* #define SUNOS4 */	/* SunOS 4.x */
-/* #define LINUX */	/* Another Unix clone */
+#define LINUX /* Another Unix clone */
+/* #define OSX	 /* Apple OS X */
 /* #define CYGWIN32 */	/* Unix on Win32 -- use with case sensitive defines */
 /* #define GENIX */	/* Yet Another Unix Clone */
@@ -110,9 +111,7 @@
  * If defined, it can be overridden by the environment variable PAGER.
  * Hack will use its internal pager if DEF_PAGER is not defined.
- * (This might be preferable for security reasons.)
- * #define DEF_PAGER	".../mydir/mypager"
- */
-
+ * (This might be preferable for security reasons.)*/
 
+/*#define DEF_PAGER	"/usr/bin/less"*/
 
 /*
@@ -133,5 +132,5 @@
  * a fine-grained timer.
  */
-/* #define TIMED_DELAY */	/* usleep() */
+#define TIMED_DELAY /* usleep() */
 #endif
 
@@ -144,5 +143,5 @@
  */
 
-#define MAIL			/* Deliver mail during the game */
+/* #define MAIL			/* Deliver mail during the game */
 
 /* The Andrew Message System does mail a little differently from normal
@@ -210,4 +209,10 @@
 #define FCMASK	0660	/* file creation mask */
 
+/* fcntl(2) is a POSIX-portable call for manipulating file descriptors.
+ * Comment out the USE_FCNTL if for some reason you have a strange
+ * os/filesystem combination for which fcntl(2) does not work. */
+#ifdef POSIX_TYPES
+# define USE_FCNTL
+#endif
 
 /*
@@ -271,5 +276,5 @@
 #define tgetch getchar
 
-#define SHELL		/* do not delete the '!' command */
+/* #define SHELL		do not delete the '!' command */
 
 #include "system.h"
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/wincurs.h nethack/include/wincurs.h
--- nh_orig/include/wincurs.h	1969-12-31 19:00:00.000000000 -0500
+++ nethack/include/wincurs.h	2009-09-05 11:30:14.265303603 -0400
@@ -0,0 +1,250 @@
+#ifndef WINCURS_H
+#define WINCURS_H
+
+/* Global declarations for curses interface */
+
+int term_rows, term_cols; /* size of underlying terminal */
+
+WINDOW *base_term;    /* underlying terminal window */
+
+WINDOW *mapborderwin;
+
+
+#define TEXTCOLOR   /* Allow color */
+#define NHW_END 19
+#define OFF 0
+#define ON 1
+#define NONE -1
+#define KEY_ESC 0x1b
+#define DIALOG_BORDER_COLOR CLR_MAGENTA
+#define HIGHLIGHT_COLOR CLR_WHITE
+#define MORECOLOR CLR_ORANGE
+#define STAT_UP_COLOR CLR_GREEN
+#define STAT_DOWN_COLOR CLR_RED
+#define MESSAGE_WIN 1
+#define STATUS_WIN  2
+#define MAP_WIN     3
+#define HPOS_WIN    4
+#define MESG_HISTORY_MAX   200
+
+
+typedef enum orient_type
+{
+    CENTER,
+    UP,
+    DOWN,
+    RIGHT,
+    LEFT
+} orient;
+
+
+/* cursmain.c */
+
+extern struct window_procs curses_procs;
+
+extern void curses_init_nhwindows(int* argcp, char** argv);
+
+extern void curses_player_selection(void);
+
+extern void curses_askname(void);
+
+extern void curses_get_nh_event(void);
+
+extern void curses_exit_nhwindows(const char *str);
+
+extern void curses_suspend_nhwindows(const char *str);
+
+extern void curses_resume_nhwindows(void);
+
+extern winid curses_create_nhwindow(int type);
+
+extern void curses_clear_nhwindow(winid wid);
+
+extern void curses_display_nhwindow(winid wid, BOOLEAN_P block);
+
+extern void curses_destroy_nhwindow(winid wid);
+
+extern void curses_curs(winid wid, int x, int y);
+
+extern void curses_putstr(winid wid, int attr, const char *text);
+
+extern void curses_display_file(const char *filename,BOOLEAN_P must_exist);
+
+extern void curses_start_menu(winid wid);
+
+extern void curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
+		CHAR_P accelerator, CHAR_P group_accel, int attr, 
+		const char *str, BOOLEAN_P presel);
+
+extern void curses_end_menu(winid wid, const char *prompt);
+
+extern int curses_select_menu(winid wid, int how, MENU_ITEM_P **selected);
+
+extern void curses_update_inventory(void);
+
+extern void curses_mark_synch(void);
+
+extern void curses_wait_synch(void);
+
+extern void curses_cliparound(int x, int y);
+
+extern void curses_print_glyph(winid wid,XCHAR_P x,XCHAR_P y,int glyph);
+
+extern void curses_raw_print(const char *str);
+
+extern void curses_raw_print_bold(const char *str);
+
+extern int curses_nhgetch(void);
+
+extern int curses_nh_poskey(int *x, int *y, int *mod);
+
+extern void curses_nhbell(void);
+
+extern int curses_doprev_message(void);
+
+extern char curses_yn_function(const char *question, const char *choices, CHAR_P def);
+
+extern void curses_getlin(const char *question, char *input);
+
+extern int curses_get_ext_cmd(void);
+
+extern void curses_number_pad(int state);
+
+extern void curses_delay_output(void);
+
+extern void curses_start_screen(void);
+
+extern void curses_end_screen(void);
+
+extern void curses_outrip(winid wid, int how);
+
+extern void genl_outrip(winid tmpwin, int how);
+
+extern void curses_preference_update(const char *pref);
+
+
+/* curswins.c */
+
+extern WINDOW *curses_create_window(int width, int height, orient orientation);
+
+extern void curses_destroy_win(WINDOW *win);
+
+extern WINDOW *curses_get_nhwin(winid wid);
+
+extern void curses_add_nhwin(winid wid, int height, int width, int y,
+ int x, orient orientation, boolean border);
+
+extern void curses_refresh_nhwin(winid wid);
+
+extern void curses_refresh_nethack_windows(void);
+
+extern void curses_del_nhwin(winid wid);
+
+extern void curses_putch(winid wid, int x, int y, int ch, int color, int attrs);
+
+extern void curses_get_window_size(winid wid, int *height, int *width);
+
+extern boolean curses_window_has_border(winid wid);
+
+extern boolean curses_window_exists(winid wid);
+
+extern int curses_get_window_orientation(winid wid);
+
+extern void curses_get_window_xy(winid wid, int *x, int *y);
+
+extern void curses_puts(winid wid, int attr, const char *text);
+
+
+/* cursmisc.c */
+
+extern int curses_read_char(void);
+
+extern void curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff);
+
+extern void curses_bail(const char *mesg);
+
+extern winid curses_get_wid(int type);
+
+extern char *curses_copy_of(const char *s);
+
+extern int curses_num_lines(const char *str, int width);
+
+extern char *curses_break_str(const char *str, int width, int line_num);
+
+extern char *curses_str_remainder(const char *str, int width, int line_num);
+
+extern boolean curses_is_menu(winid wid);
+
+extern boolean curses_is_text(winid wid);
+
+extern int curses_convert_glyph(int ch, int glyph);
+
+extern void curses_move_cursor(winid wid, int x, int y);
+
+extern void curses_prehousekeeping(void);
+
+extern void curses_posthousekeeping(void);
+
+extern void curses_view_file(const char *filename, boolean must_exist);
+
+extern char *curses_rtrim(char *str);
+
+
+/* cursdial.c */
+
+extern void curses_line_input_dialog(const char *prompt, char *answer, int buffer);
+
+extern int curses_character_input_dialog(const char *prompt, const char *choices, CHAR_P def);
+
+extern int curses_ext_cmd(void);
+
+extern void curses_create_nhmenu(winid wid);
+
+extern void curses_add_nhmenu_item(winid wid, const ANY_P *identifier,
+ CHAR_P accelerator, CHAR_P group_accel, int attr, const char *str,
+ BOOLEAN_P presel);
+
+extern void curses_finalize_nhmenu(winid wid, const char *prompt);
+
+extern int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P **_selected);
+
+extern boolean curses_menu_exists(winid wid);
+
+extern void curses_del_menu(winid wid);
+
+
+/* cursstat.c */
+
+extern void curses_update_stats(void);
+
+extern void curses_decrement_highlight(void);
+
+
+/* cursinit.c */
+
+extern void curses_create_main_windows(void);
+
+extern void curses_init_nhcolors(void);
+
+extern void curses_choose_character(void);
+
+extern int curses_character_dialog(const char** choices, const char *prompt);
+
+extern void curses_init_options(void);
+
+
+/* cursmesg.c */
+
+extern void curses_message_win_puts(const char *message, boolean recursed);
+
+extern void curses_more(void);
+
+extern void curses_clear_unhighlight_message_window(void);
+
+extern void curses_last_messages(void);
+
+extern void curses_init_mesg_history(void);
+
+
+#endif  /* WINCURS_H */
+
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/you.h nethack/include/you.h
--- nh_orig/include/you.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/you.h	2009-10-25 09:36:54.251272566 -0400
@@ -89,9 +89,5 @@
 	      ldrnum,		/* PM_ of quest leader (questpgr.c) */
 	      guardnum,		/* PM_ of quest guardians (questpgr.c) */
-	      neminum,		/* PM_ of quest nemesis (questpgr.c) */
-	      enemy1num,	/* specific quest enemies (NON_PM == random) */
-	      enemy2num;
-	char  enemy1sym,	/* quest enemies by class (S_) */
-	      enemy2sym;
+	      neminum;		/* PM_ of quest nemesis (questpgr.c) */
 	short questarti;	/* index (ART_) of quest artifact (questpgr.c) */
 
@@ -345,4 +341,5 @@
 	long	ucleansed;	/* to record moves when player was cleansed */
 	long	usleep;		/* sleeping; monstermove you last started */
+	long  udiseased;  /* diseased: are you diseased, and how badly? */
 	int uinvault;
 	struct monst *ustuck;
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/include/youprop.h nethack/include/youprop.h
--- nh_orig/include/youprop.h	2003-12-07 18:39:13.000000000 -0500
+++ nethack/include/youprop.h	2009-08-02 13:49:33.040407823 -0400
@@ -61,4 +61,24 @@
 				 resists_drli(&youmonst))
 
+#define HVulnerable_fire  u.uprops[VULN_FIRE].intrinsic
+#define EVulnerable_fire  u.uprops[VULN_FIRE].extrinsic
+#define Vulnerable_fire	  (HVulnerable_fire || EVulnerable_fire || \
+		vulnerable_to(&youmonst,AD_FIRE))
+
+#define HVulnerable_cold  u.uprops[VULN_COLD].intrinsic
+#define EVulnerable_cold  u.uprops[VULN_COLD].extrinsic
+#define Vulnerable_cold	  (HVulnerable_cold || EVulnerable_cold || \
+		vulnerable_to(&youmonst,AD_COLD))
+
+#define HVulnerable_elec  u.uprops[VULN_ELEC].intrinsic
+#define EVulnerable_elec  u.uprops[VULN_ELEC].extrinsic
+#define Vulnerable_elec	  (HVulnerable_elec || EVulnerable_elec || \
+		vulnerable_to(&youmonst,AD_ELEC))
+
+#define HVulnerable_acid  u.uprops[VULN_ACID].intrinsic
+#define EVulnerable_acid  u.uprops[VULN_ACID].extrinsic
+#define Vulnerable_acid	  (HVulnerable_acid || EVulnerable_acid || \
+		vulnerable_to(&youmonst,AD_ACID))
+
 /* Intrinsics only */
 #define HSick_resistance	u.uprops[SICK_RES].intrinsic
@@ -80,4 +100,10 @@
 #define Stone_resistance	(EStone_resistance || resists_ston(&youmonst))
 
+#define EWere_resistance  u.uprops[WERE_RES].extrinsic
+#define Were_resistance	  (EWere_resistance)
+
+#define EBlind_resistance  u.uprops[BLIND_RES].extrinsic
+#define Blind_resistance	(EBlind_resistance || Vision)
+
 
 /*** Troubles ***/
@@ -87,10 +113,16 @@
 /* Those implemented solely as timeouts (we use just intrinsic) */
 #define HStun			u.uprops[STUNNED].intrinsic
-#define Stunned			(HStun || u.umonnum == PM_STALKER || \
-				 youmonst.data->mlet == S_BAT)
+#define Stunned			(!Stun_resistance && \
+							(HStun || u.umonnum == PM_STALKER || youmonst.data->mlet == S_BAT))
 		/* Note: birds will also be stunned */
 
 #define HConfusion		u.uprops[CONFUSION].intrinsic
-#define Confusion		HConfusion
+#define Confusion					  (HConfusion && !Confusion_resistance)
+
+/* cheap hack to avoid breaking save */
+#define EConfusion_resistance	  u.uprops[CONFUSION].extrinsic
+#define Confusion_resistance	  EConfusion_resistance
+#define EStun_resistance		  u.uprops[STUNNED].extrinsic
+#define Stun_resistance			  EStun_resistance
 
 #define Blinded			u.uprops[BLINDED].intrinsic
@@ -98,7 +130,10 @@
 		/* ...means blind because of a cover */
 #define Blind	((Blinded || Blindfolded || !haseyes(youmonst.data)) && \
-		 !(ublindf && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD))
+		 !(ublindf && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD) && \
+		 !(haseyes(youmonst.data) && Blind_resistance))
+
 		/* ...the Eyes operate even when you really are blind
-		    or don't have any eyes */
+		    or don't have any eyes, but blindness resistance won't
+			 grant sight to something that didn't have it... */
 
 #define Sick			u.uprops[SICK].intrinsic
@@ -112,5 +147,5 @@
 #define HHallucination		u.uprops[HALLUC].intrinsic
 #define EHalluc_resistance	u.uprops[HALLUC_RES].extrinsic
-#define Halluc_resistance	(EHalluc_resistance || \
+#define Halluc_resistance	(EHalluc_resistance || Vision || \
 				 (Upolyd && dmgtype(youmonst.data, AD_HALU)))
 #define Hallucination		(HHallucination && !Halluc_resistance)
@@ -138,11 +173,12 @@
 #define ESee_invisible		u.uprops[SEE_INVIS].extrinsic
 #define See_invisible		(HSee_invisible || ESee_invisible || \
-				 perceives(youmonst.data))
+				 perceives(youmonst.data) || Vision)
 
 #define HTelepat		u.uprops[TELEPAT].intrinsic
 #define ETelepat		u.uprops[TELEPAT].extrinsic
-#define Blind_telepat		(HTelepat || ETelepat || \
-				 telepathic(youmonst.data))
-#define Unblind_telepat		(ETelepat)
+#define Blind_telepat		((HTelepat || ETelepat || \
+				 telepathic(youmonst.data)) && !BTelepat)
+#define Unblind_telepat		(ETelepat && !BTelepat)
+#define BTelepat	 u.uprops[TELEPAT].blocked
 
 #define HWarning		u.uprops[WARNING].intrinsic
@@ -150,4 +186,10 @@
 #define Warning			(HWarning || EWarning)
 
+/* See invisible, infravision, protection from shape changers,
+ * blindness and hallucination resistance all rolled into one */
+#define EVision		 u.uprops[VISION].extrinsic
+#define Vision			 (EVision)
+
+
 /* Warning for a specific type of monster */
 #define HWarn_of_mon		u.uprops[WARN_OF_MON].intrinsic
@@ -171,5 +213,5 @@
 #define EInfravision		u.uprops[INFRAVISION].extrinsic
 #define Infravision		(HInfravision || EInfravision || \
-				  infravision(youmonst.data))
+				  infravision(youmonst.data) || Vision)
 
 #define HDetect_monsters	u.uprops[DETECT_MONSTERS].intrinsic
@@ -241,4 +283,5 @@
 	/* May touch surface; does not override any others */
 
+#define EWwalking	   u.uprops[WWALKING].extrinsic
 #define Wwalking		(u.uprops[WWALKING].extrinsic && \
 				 !Is_waterlevel(&u.uz))
@@ -310,5 +353,6 @@
 #define Protection_from_shape_changers \
 				(HProtection_from_shape_changers || \
-				 EProtection_from_shape_changers)
+				 EProtection_from_shape_changers || \
+				 Vision)
 
 #define HPolymorph		u.uprops[POLYMORPH].intrinsic
@@ -326,9 +370,14 @@
 #define HFast			u.uprops[FAST].intrinsic
 #define EFast			u.uprops[FAST].extrinsic
-#define Fast			(HFast || EFast)
-#define Very_fast		((HFast & ~INTRINSIC) || EFast)
+#define Fast			((HFast || EFast) && !Slow)
+#define Very_fast		(((HFast & ~INTRINSIC) || EFast) && !Slow)
+
+#define HSlow		   u.uprops[SLOW].intrinsic
+#define ESlow		   u.uprops[SLOW].extrinsic
+#define Slow			(HSlow || ESlow)
 
+#define HReflecting		u.uprops[REFLECTING].intrinsic
 #define EReflecting		u.uprops[REFLECTING].extrinsic
-#define Reflecting		(EReflecting || \
+#define Reflecting		(EReflecting || HReflecting || \
 				 (youmonst.data == &mons[PM_SILVER_DRAGON]))
 
@@ -339,4 +388,6 @@
 #define Lifesaved		u.uprops[LIFESAVED].extrinsic
 
+#define ELucky				u.uprops[LUCKY].extrinsic
+#define Lucky				(ELucky)
 
 #endif /* YOUPROP_H */
diff -X /home/derek/bin/nhdiff_exceptions -iNdEwr -U2 nh_orig/nh343-curses-a2.patch nethack/nh343-curses-a2.patch
--- nh_orig/nh343-curses-a2.patch	1969-12-31 19:00:00.000000000 -0500
+++ nethack/nh343-curses-a2.patch	2009-09-05 10:31:56.532294000 -0400
@@ -0,0 +1,9003 @@
+diff -burN nethack-3.4.3/doc/window.doc nethack/doc/window.doc
+--- nethack-3.4.3/doc/window.doc	2003-12-07 18:39:13.000000000 -0500
++++ nethack/doc/window.doc	2009-03-11 13:33:19.000000000 -0400
+@@ -518,6 +518,9 @@
+   |  fullscreen        | WC2_FULLSCREEN     | wc2_fullscreen     |boolean |
+   |  softkeyboard      | WC2_SOFTKEYBOARD   | wc2_softkeyboard   |boolean |
+   |  wraptext          | WC2_WRAPTEXT       | wc2_wraptext       |boolean |
++  |  term_cols         | WC2_TERM_COLS      | wc2_term_cols      |int     |
++  |  term_rows         | WC2_TERM_ROWS      | wc2_term_rows      |int     |
++  |  windowborders     | WC2_WINDOWBORDERS  | wc2_windowborders  |int     |
+   +--------------------+--------------------+--------------------+--------+
+ 
+ align_message	-- where to place message window (top, bottom, left, right)
+@@ -548,6 +551,8 @@
+ 		   is this number of cells away from the edge of the window.
+ softkeyboard    -- handhelds should display an on-screen keyboard if possible.
+ splash_screen   -- port should/should not display an opening splashscreen.
++term_cols       -- Terminal should size itself to specified width, if possible.
++term_rows       -- Terminal should size itself to specified height, if possible.
+ tiled_map	-- port should display a tiled map if it can.
+ tile_width	-- port should display tiles with this width or round to closest
+ 		   if it can.
+@@ -558,6 +563,8 @@
+ use_inverse	-- port should display inverse when NetHack asks for it.
+ vary_msgcount	-- port should display this number of messages at a time in
+ 		   the message window.
++windowborders   -- port should display borders around main NetHack windows.
++                Can be set to (1) on, (2) off, or (3) auto.
+ windowcolors
+ 		-- port should use these colors for window foreground/background
+ 		   colors.  Syntax:
+diff -burN nethack-3.4.3/include/config.h nethack/include/config.h
+--- nethack-3.4.3/include/config.h	2003-12-07 18:39:13.000000000 -0500
++++ nethack/include/config.h	2009-03-05 13:50:37.000000000 -0500
+@@ -42,7 +42,8 @@
+  * Define all of those you want supported in your binary.
+  * Some combinations make no sense.  See the installation document.
+  */
+-#define TTY_GRAPHICS	/* good old tty based graphics */
++/* #define TTY_GRAPHICS */	/* good old tty based graphics */
++#define CURSES_GRAPHICS     /* Proper curses interface */
+ /* #define X11_GRAPHICS */	/* X11 interface */
+ /* #define QT_GRAPHICS */	/* Qt interface */
+ /* #define GNOME_GRAPHICS */	/* Gnome interface */
+@@ -113,6 +114,15 @@
+ # define HACKDIR "\\nethack"
+ #endif
+ 
++#ifdef CURSES_GRAPHICS
++# ifdef TTY_GRAPHICS
++# undef TTY_GRAPHICS
++# endif
++# ifndef DEFAULT_WINDOW_SYS
++#  define DEFAULT_WINDOW_SYS "curses"
++# endif
++#endif
++
+ #ifndef DEFAULT_WINDOW_SYS
+ # define DEFAULT_WINDOW_SYS "tty"
+ #endif
+@@ -169,11 +179,11 @@
+ 
+ #ifdef UNIX
+ /* path and file name extension for compression program */
+-#define COMPRESS "/usr/bin/compress"	/* Lempel-Ziv compression */
+-#define COMPRESS_EXTENSION ".Z"		/* compress's extension */
++/* #define COMPRESS "/usr/bin/compress" */	/* Lempel-Ziv compression */
++/* #define COMPRESS_EXTENSION ".Z"	*/	/* compress's extension */
+ /* An example of one alternative you might want to use: */
+-/* #define COMPRESS "/usr/local/bin/gzip" */	/* FSF gzip compression */
+-/* #define COMPRESS_EXTENSION ".gz" */		/* normal gzip extension */
++#define COMPRESS "/bin/gzip"	/* FSF gzip compression */
++#define COMPRESS_EXTENSION ".gz"		/* normal gzip extension */
+ #endif
+ 
+ #ifndef COMPRESS
+diff -burN nethack-3.4.3/include/flag.h nethack/include/flag.h
+--- nethack-3.4.3/include/flag.h	2003-12-07 18:39:13.000000000 -0500
++++ nethack/include/flag.h	2009-03-05 13:50:37.000000000 -0500
+@@ -156,6 +156,7 @@
+ 
+ struct instance_flags {
+ 	boolean  cbreak;	/* in cbreak mode, rogue format */
++    boolean  cursesgraphics;    /* Use portable curses extended characters */
+ 	boolean  DECgraphics;	/* use DEC VT-xxx extended character set */
+ 	boolean  echo;		/* 1 to echo characters */
+ 	boolean  IBMgraphics;	/* use IBM extended character set */
+@@ -181,6 +182,8 @@
+ #endif
+ #ifdef TTY_GRAPHICS
+ 	char prevmsg_window;	/* type of old message window to use */
++#endif
++#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
+ 	boolean  extmenu;	/* extended commands use menu interface */
+ #endif
+ #ifdef MFLOPPY
+@@ -263,6 +266,9 @@
+ 	boolean wc2_fullscreen;		/* run fullscreen */
+ 	boolean wc2_softkeyboard;	/* use software keyboard */
+ 	boolean wc2_wraptext;		/* wrap text */
++    int     wc2_term_cols;      /* terminal width, in characters */
++    int     wc2_term_rows;      /* terminal height, in characters */
++    int     wc2_windowborders;  /* display borders on NetHack windows */
+ 
+ 	boolean  cmdassist;	/* provide detailed assistance for some commands */
+ 	boolean	 obsolete;	/* obsolete options can point at this, it isn't used */
+diff -burN nethack-3.4.3/include/ntconf.h nethack/include/ntconf.h
+--- nethack-3.4.3/include/ntconf.h	2003-12-07 18:39:13.000000000 -0500
++++ nethack/include/ntconf.h	2009-03-11 13:27:04.000000000 -0400
+@@ -159,7 +159,9 @@
+ long _RTLENTRY _EXPFUNC lseek  (int __handle, long __offset, int __fromwhere);
+ int  _RTLENTRY _EXPFUNC read  (int __handle, void _FAR *__buf, unsigned __len);
+ #endif
+-#include <conio.h>
++#ifndef CURSES_GRAPHICS
++# include <conio.h>
++#endif
+ #undef kbhit		/* Use our special NT kbhit */
+ #define kbhit (*nt_kbhit)
+ 
+diff -burN nethack-3.4.3/include/rm.h nethack/include/rm.h
+--- nethack-3.4.3/include/rm.h	2003-12-07 18:39:13.000000000 -0500
++++ nethack/include/rm.h	2009-03-05 13:50:38.000000000 -0500
+@@ -234,6 +234,7 @@
+ #define IBM_GRAPHICS	1	/* PC graphic characters */
+ #define DEC_GRAPHICS	2	/* VT100 line drawing characters */
+ #define MAC_GRAPHICS	3	/* Macintosh drawing characters */
++#define CURS_GRAPHICS   4   /* Portable curses drawing characters */
+ 
+ /*
+  * The 5 possible states of doors
+diff -burN nethack-3.4.3/include/wincurs.h nethack/include/wincurs.h
+--- nethack-3.4.3/include/wincurs.h	1969-12-31 19:00:00.000000000 -0500
++++ nethack/include/wincurs.h	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,250 @@
++#ifndef WINCURS_H
++#define WINCURS_H
++
++/* Global declarations for curses interface */
++
++int term_rows, term_cols; /* size of underlying terminal */
++
++WINDOW *base_term;    /* underlying terminal window */
++
++WINDOW *mapborderwin;
++
++
++#define TEXTCOLOR   /* Allow color */
++#define NHW_END 19
++#define OFF 0
++#define ON 1
++#define NONE -1
++#define KEY_ESC 0x1b
++#define DIALOG_BORDER_COLOR CLR_MAGENTA
++#define HIGHLIGHT_COLOR CLR_WHITE
++#define MORECOLOR CLR_ORANGE
++#define STAT_UP_COLOR CLR_GREEN
++#define STAT_DOWN_COLOR CLR_RED
++#define MESSAGE_WIN 1
++#define STATUS_WIN  2
++#define MAP_WIN     3
++#define HPOS_WIN    4
++#define MESG_HISTORY_MAX   200
++
++
++typedef enum orient_type
++{
++    CENTER,
++    UP,
++    DOWN,
++    RIGHT,
++    LEFT
++} orient;
++
++
++/* cursmain.c */
++
++extern struct window_procs curses_procs;
++
++extern void curses_init_nhwindows(int* argcp, char** argv);
++
++extern void curses_player_selection(void);
++
++extern void curses_askname(void);
++
++extern void curses_get_nh_event(void);
++
++extern void curses_exit_nhwindows(const char *str);
++
++extern void curses_suspend_nhwindows(const char *str);
++
++extern void curses_resume_nhwindows(void);
++
++extern winid curses_create_nhwindow(int type);
++
++extern void curses_clear_nhwindow(winid wid);
++
++extern void curses_display_nhwindow(winid wid, BOOLEAN_P block);
++
++extern void curses_destroy_nhwindow(winid wid);
++
++extern void curses_curs(winid wid, int x, int y);
++
++extern void curses_putstr(winid wid, int attr, const char *text);
++
++extern void curses_display_file(const char *filename,BOOLEAN_P must_exist);
++
++extern void curses_start_menu(winid wid);
++
++extern void curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
++		CHAR_P accelerator, CHAR_P group_accel, int attr, 
++		const char *str, BOOLEAN_P presel);
++
++extern void curses_end_menu(winid wid, const char *prompt);
++
++extern int curses_select_menu(winid wid, int how, MENU_ITEM_P **selected);
++
++extern void curses_update_inventory(void);
++
++extern void curses_mark_synch(void);
++
++extern void curses_wait_synch(void);
++
++extern void curses_cliparound(int x, int y);
++
++extern void curses_print_glyph(winid wid,XCHAR_P x,XCHAR_P y,int glyph);
++
++extern void curses_raw_print(const char *str);
++
++extern void curses_raw_print_bold(const char *str);
++
++extern int curses_nhgetch(void);
++
++extern int curses_nh_poskey(int *x, int *y, int *mod);
++
++extern void curses_nhbell(void);
++
++extern int curses_doprev_message(void);
++
++extern char curses_yn_function(const char *question, const char *choices, CHAR_P def);
++
++extern void curses_getlin(const char *question, char *input);
++
++extern int curses_get_ext_cmd(void);
++
++extern void curses_number_pad(int state);
++
++extern void curses_delay_output(void);
++
++extern void curses_start_screen(void);
++
++extern void curses_end_screen(void);
++
++extern void curses_outrip(winid wid, int how);
++
++extern void genl_outrip(winid tmpwin, int how);
++
++extern void curses_preference_update(const char *pref);
++
++
++/* curswins.c */
++
++extern WINDOW *curses_create_window(int width, int height, orient orientation);
++
++extern void curses_destroy_win(WINDOW *win);
++
++extern WINDOW *curses_get_nhwin(winid wid);
++
++extern void curses_add_nhwin(winid wid, int height, int width, int y,
++ int x, orient orientation, boolean border);
++
++extern void curses_refresh_nhwin(winid wid);
++
++extern void curses_refresh_nethack_windows(void);
++
++extern void curses_del_nhwin(winid wid);
++
++extern void curses_putch(winid wid, int x, int y, int ch, int color, int attrs);
++
++extern void curses_get_window_size(winid wid, int *height, int *width);
++
++extern boolean curses_window_has_border(winid wid);
++
++extern boolean curses_window_exists(winid wid);
++
++extern int curses_get_window_orientation(winid wid);
++
++extern void curses_get_window_xy(winid wid, int *x, int *y);
++
++extern void curses_puts(winid wid, int attr, const char *text);
++
++
++/* cursmisc.c */
++
++extern int curses_read_char(void);
++
++extern void curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff);
++
++extern void curses_bail(const char *mesg);
++
++extern winid curses_get_wid(int type);
++
++extern char *curses_copy_of(const char *s);
++
++extern int curses_num_lines(const char *str, int width);
++
++extern char *curses_break_str(const char *str, int width, int line_num);
++
++extern char *curses_str_remainder(const char *str, int width, int line_num);
++
++extern boolean curses_is_menu(winid wid);
++
++extern boolean curses_is_text(winid wid);
++
++extern int curses_convert_glyph(int ch, int glyph);
++
++extern void curses_move_cursor(winid wid, int x, int y);
++
++extern void curses_prehousekeeping(void);
++
++extern void curses_posthousekeeping(void);
++
++extern void curses_view_file(const char *filename, boolean must_exist);
++
++extern char *curses_rtrim(char *str);
++
++
++/* cursdial.c */
++
++extern void curses_line_input_dialog(const char *prompt, char *answer, int buffer);
++
++extern int curses_character_input_dialog(const char *prompt, const char *choices, CHAR_P def);
++
++extern int curses_ext_cmd(void);
++
++extern void curses_create_nhmenu(winid wid);
++
++extern void curses_add_nhmenu_item(winid wid, const ANY_P *identifier,
++ CHAR_P accelerator, CHAR_P group_accel, int attr, const char *str,
++ BOOLEAN_P presel);
++
++extern void curses_finalize_nhmenu(winid wid, const char *prompt);
++
++extern int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P **_selected);
++
++extern boolean curses_menu_exists(winid wid);
++
++extern void curses_del_menu(winid wid);
++
++
++/* cursstat.c */
++
++extern void curses_update_stats(void);
++
++extern void curses_decrement_highlight(void);
++
++
++/* cursinit.c */
++
++extern void curses_create_main_windows(void);
++
++extern void curses_init_nhcolors(void);
++
++extern void curses_choose_character(void);
++
++extern int curses_character_dialog(const char** choices, const char *prompt);
++
++extern void curses_init_options(void);
++
++
++/* cursmesg.c */
++
++extern void curses_message_win_puts(const char *message, boolean recursed);
++
++extern void curses_more(void);
++
++extern void curses_clear_unhighlight_message_window(void);
++
++extern void curses_last_messages(void);
++
++extern void curses_init_mesg_history(void);
++
++
++#endif  /* WINCURS_H */
++
+diff -burN nethack-3.4.3/include/winprocs.h nethack/include/winprocs.h
+--- nethack-3.4.3/include/winprocs.h	2003-12-07 18:39:13.000000000 -0500
++++ nethack/include/winprocs.h	2009-03-05 13:50:38.000000000 -0500
+@@ -176,8 +176,11 @@
+ 
+ #define WC2_FULLSCREEN		0x01L	/* 01 display full screen                    */
+ #define WC2_SOFTKEYBOARD	0x02L	/* 02 software keyboard                      */
+-#define WC2_WRAPTEXT		0x04L	/* 04 wrap long lines of text                */
+-					/* 29 free bits */
++#define WC2_WRAPTEXT		0x04L	/* 03 wrap long lines of text                */
++#define WC2_TERM_COLS		0x08L	/* 04 supports setting terminal width        */
++#define WC2_TERM_ROWS		0x10L	/* 05 supports setting terminal height       */
++#define WC2_WINDOWBORDERS	0x20L	/* 06 display borders for NetHack windows    */
++					/* 26 free bits */
+ 
+ #define ALIGN_LEFT	1
+ #define ALIGN_RIGHT	2
+diff -burN nethack-3.4.3/src/cmd.c nethack/src/cmd.c
+--- nethack-3.4.3/src/cmd.c	2003-12-07 18:39:13.000000000 -0500
++++ nethack/src/cmd.c	2009-03-05 13:50:38.000000000 -0500
+@@ -322,7 +322,7 @@
+ 	return 0;
+ }
+ 
+-#ifdef TTY_GRAPHICS
++#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
+ #define MAX_EXT_CMD 40		/* Change if we ever have > 40 ext cmds */
+ /*
+  * This is currently used only by the tty port and is
+diff -burN nethack-3.4.3/src/drawing.c nethack/src/drawing.c
+--- nethack-3.4.3/src/drawing.c	2003-12-07 18:39:13.000000000 -0500
++++ nethack/src/drawing.c	2009-03-05 13:50:38.000000000 -0500
+@@ -4,7 +4,6 @@
+ 
+ #include "hack.h"
+ #include "tcap.h"
+-
+ /* Relevent header information in rm.h and objclass.h. */
+ 
+ #ifdef C
+@@ -314,6 +313,10 @@
+ void NDECL((*ibmgraphics_mode_callback)) = 0;	/* set in tty_start_screen() */
+ #endif /* PC9800 */
+ 
++#ifdef CURSES_GRAPHICS
++void NDECL((*cursesgraphics_mode_callback)) = 0;
++#endif
++
+ static uchar ibm_graphics[MAXPCHARS] = {
+ /* 0*/	g_FILLER(S_stone),
+ 	0xb3,	/* S_vwall:	meta-3, vertical rule */
+@@ -674,6 +677,9 @@
+  */
+ 	    iflags.IBMgraphics = TRUE;
+ 	    iflags.DECgraphics = FALSE;
++#ifdef CURSES_GRAPHICS
++        iflags.cursesgraphics = FALSE;
++#endif
+ 	    assign_graphics(ibm_graphics, SIZE(ibm_graphics), MAXPCHARS, 0);
+ #ifdef PC9800
+ 	    if (ibmgraphics_mode_callback) (*ibmgraphics_mode_callback)();
+@@ -687,6 +693,9 @@
+  */
+ 	    iflags.DECgraphics = TRUE;
+ 	    iflags.IBMgraphics = FALSE;
++#ifdef CURSES_GRAPHICS
++        iflags.cursesgraphics = FALSE;
++#endif
+ 	    assign_graphics(dec_graphics, SIZE(dec_graphics), MAXPCHARS, 0);
+ 	    if (decgraphics_mode_callback) (*decgraphics_mode_callback)();
+ 	    break;
+@@ -696,6 +705,12 @@
+ 	    assign_graphics(mac_graphics, SIZE(mac_graphics), MAXPCHARS, 0);
+ 	    break;
+ #endif
++#ifdef CURSES_GRAPHICS
++    case CURS_GRAPHICS:
++	    iflags.IBMgraphics = FALSE;
++	    iflags.DECgraphics = FALSE;
++        break;
++#endif
+ 	}
+     return;
+ }
+diff -burN nethack-3.4.3/src/options.c nethack/src/options.c
+--- nethack-3.4.3/src/options.c	2003-12-07 18:39:13.000000000 -0500
++++ nethack/src/options.c	2009-03-05 13:50:38.000000000 -0500
+@@ -69,19 +69,24 @@
+ 	{"checkspace", (boolean *)0, FALSE, SET_IN_FILE},
+ #endif
+ 	{"cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME},
+-# if defined(MICRO) || defined(WIN32)
++# if defined(MICRO) || defined(WIN32) || defined(CURSES_GRAPHICS)
+ 	{"color",         &iflags.wc_color,TRUE, SET_IN_GAME},		/*WC*/
+ # else	/* systems that support multiple terminals, many monochrome */
+ 	{"color",         &iflags.wc_color, FALSE, SET_IN_GAME},	/*WC*/
+ # endif
+ 	{"confirm",&flags.confirm, TRUE, SET_IN_GAME},
++#ifdef CURSES_GRAPHICS
++	{"cursesgraphics", &iflags.cursesgraphics, TRUE, SET_IN_GAME},
++#else
++	{"cursesgraphics", (boolean *)0, FALSE, SET_IN_FILE},
++#endif
+ #if defined(TERMLIB) && !defined(MAC_GRAPHICS_ENV)
+ 	{"DECgraphics", &iflags.DECgraphics, FALSE, SET_IN_GAME},
+ #else
+ 	{"DECgraphics", (boolean *)0, FALSE, SET_IN_FILE},
+ #endif
+ 	{"eight_bit_tty", &iflags.wc_eight_bit_input, FALSE, SET_IN_GAME},	/*WC*/
+-#ifdef TTY_GRAPHICS
++#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
+ 	{"extmenu", &iflags.extmenu, FALSE, SET_IN_GAME},
+ #else
+ 	{"extmenu", (boolean *)0, FALSE, SET_IN_FILE},
+@@ -2043,6 +2048,49 @@
+ 		return;
+ 	}
+ 
++	/* WINCAP2
++	 * term_cols:amount */
++	fullname = "term_cols";
++	if (match_optname(opts, fullname, sizeof("term_cols")-1, TRUE)) {
++		op = string_for_opt(opts, negated);
++		iflags.wc2_term_cols = atoi(op);
++		if (negated) bad_negation(fullname, FALSE);
++		return;
++	}
++
++	/* WINCAP2
++	 * term_rows:amount */
++	fullname = "term_rows";
++	if (match_optname(opts, fullname, sizeof("term_rows")-1, TRUE)) {
++		op = string_for_opt(opts, negated);
++		iflags.wc2_term_rows = atoi(op);
++		if (negated) bad_negation(fullname, FALSE);
++		return;
++	}
++
++
++	/* WINCAP2
++	 * windowborders:n */
++	fullname = "windowborders";
++	if (match_optname(opts, fullname, sizeof("windowborders")-1, TRUE)) {
++		op = string_for_opt(opts, negated);
++		if (negated && op) bad_negation(fullname, TRUE);
++		else {
++		    if (negated)
++		        iflags.wc2_windowborders = 2; /* Off */
++		    else if (!op)
++		        iflags.wc2_windowborders = 1; /* On */
++		    else    /* Value supplied */
++		        iflags.wc2_windowborders = atoi(op);
++		    if ((iflags.wc2_windowborders > 3) ||
++		     (iflags.wc2_windowborders < 1)) {
++		        iflags.wc2_windowborders = 0;
++		        badoption(opts);
++		    }
++		}
++		return;
++	}
++
+ 	/* menustyle:traditional or combo or full or partial */
+ 	if (match_optname(opts, "menustyle", 4, TRUE)) {
+ 		int tmp;
+@@ -2149,7 +2197,7 @@
+ 
+ 			duplicate_opt_detection(boolopt[i].name, 0);
+ 
+-#if defined(TERMLIB) || defined(ASCIIGRAPH) || defined(MAC_GRAPHICS_ENV)
++#if defined(TERMLIB) || defined(ASCIIGRAPH) || defined(MAC_GRAPHICS_ENV) || defined(CURSES_GRAPHICS)
+ 			if (FALSE
+ # ifdef TERMLIB
+ 				 || (boolopt[i].addr) == &iflags.DECgraphics
+@@ -2160,6 +2208,9 @@
+ # ifdef MAC_GRAPHICS_ENV
+ 				 || (boolopt[i].addr) == &iflags.MACgraphics
+ # endif
++# ifdef CURSES_GRAPHICS
++				 || (boolopt[i].addr) == &iflags.cursesgraphics
++# endif
+ 				) {
+ # ifdef REINCARNATION
+ 			    if (!initial && Is_rogue_level(&u.uz))
+@@ -2181,6 +2232,11 @@
+ 				switch_graphics(iflags.MACgraphics ?
+ 						MAC_GRAPHICS : ASCII_GRAPHICS);
+ # endif
++# ifdef CURSES_GRAPHICS
++			    if ((boolopt[i].addr) == &iflags.cursesgraphics)
++				switch_graphics(iflags.cursesgraphics ?
++						CURS_GRAPHICS : ASCII_GRAPHICS);
++# endif
+ # ifdef REINCARNATION
+ 			    if (!initial && Is_rogue_level(&u.uz))
+ 				assign_rogue_graphics(TRUE);
+@@ -2226,6 +2282,11 @@
+ 					(boolopt[i].addr) == &iflags.hilite_pet) {
+ 			    need_redraw = TRUE;
+ 			}
++#ifdef CURSES_GRAPHICS
++			else if ((boolopt[i].addr) == &iflags.cursesgraphics) {
++			    need_redraw = TRUE;
++			}
++#endif
+ #ifdef TEXTCOLOR
+ 			else if ((boolopt[i].addr) == &iflags.use_color) {
+ 			    need_redraw = TRUE;
+@@ -3087,6 +3148,14 @@
+ 			FEATURE_NOTICE_VER_MIN,
+ 			FEATURE_NOTICE_VER_PATCH);
+ 	}
++	else if (!strcmp(optname, "term_cols")) {
++		if (iflags.wc2_term_cols) Sprintf(buf, "%d",iflags.wc2_term_cols);
++		else Strcpy(buf, defopt);
++	}
++	else if (!strcmp(optname, "term_rows")) {
++		if (iflags.wc2_term_rows) Sprintf(buf, "%d",iflags.wc2_term_rows);
++		else Strcpy(buf, defopt);
++	}
+ 	else if (!strcmp(optname, "tile_file"))
+ 		Sprintf(buf, "%s", iflags.wc_tile_file ? iflags.wc_tile_file : defopt);
+ 	else if (!strcmp(optname, "tile_height")) {
+@@ -3120,6 +3189,11 @@
+ 			ttycolors[CLR_BRIGHT_MAGENTA],
+ 			ttycolors[CLR_BRIGHT_CYAN]);
+ #endif /* VIDEOSHADES */
++	else if (!strcmp(optname,"windowborders"))
++		Sprintf(buf, "%s", iflags.wc2_windowborders == 1     ? "1=on" :
++				   iflags.wc2_windowborders == 2             ? "2=off" :
++				   iflags.wc2_windowborders == 3             ? "3=auto" :
++				   defopt);
+ 	else if (!strcmp(optname, "windowtype"))
+ 		Sprintf(buf, "%s", windowprocs.name);
+ 	else if (!strcmp(optname, "windowcolors"))
+@@ -3593,6 +3667,9 @@
+ 	{"fullscreen", WC2_FULLSCREEN},
+ 	{"softkeyboard", WC2_SOFTKEYBOARD},
+ 	{"wraptext", WC2_WRAPTEXT},
++	{"term_cols", WC2_TERM_COLS},
++	{"term_rows", WC2_TERM_ROWS},
++	{"windowborders", WC2_WINDOWBORDERS},
+ 	{(char *)0, 0L}
+ };
+ 
+diff -burN nethack-3.4.3/src/rip.c nethack/src/rip.c
+--- nethack-3.4.3/src/rip.c	2003-12-07 18:39:13.000000000 -0500
++++ nethack/src/rip.c	2009-03-05 13:50:38.000000000 -0500
+@@ -8,7 +8,7 @@
+ 
+ extern const char * const killed_by_prefix[];	/* from topten.c */
+ 
+-#if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_GRAPHICS)
++#if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_GRAPHICS) || defined(CURSES_GRAPHICS)
+ # define TEXT_TOMBSTONE
+ #endif
+ #if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
+diff -burN nethack-3.4.3/src/windows.c nethack/src/windows.c
+--- nethack-3.4.3/src/windows.c	2003-12-07 18:39:13.000000000 -0500
++++ nethack/src/windows.c	2009-03-05 13:50:38.000000000 -0500
+@@ -6,6 +6,9 @@
+ #ifdef TTY_GRAPHICS
+ #include "wintty.h"
+ #endif
++#ifdef CURSES_GRAPHICS
++extern struct window_procs curses_procs;
++#endif
+ #ifdef X11_GRAPHICS
+ /* cannot just blindly include winX.h without including all of X11 stuff */
+ /* and must get the order of include files right.  Don't bother */
+@@ -53,6 +56,9 @@
+ #ifdef TTY_GRAPHICS
+     { &tty_procs, win_tty_init },
+ #endif
++#ifdef CURSES_GRAPHICS
++    { &curses_procs, 0 },
++#endif
+ #ifdef X11_GRAPHICS
+     { &X11_procs, win_X11_init },
+ #endif
+diff -burN nethack-3.4.3/sys/unix/Makefile.src nethack/sys/unix/Makefile.src
+--- nethack-3.4.3/sys/unix/Makefile.src	2003-12-07 18:39:13.000000000 -0500
++++ nethack/sys/unix/Makefile.src	2009-03-05 13:50:38.000000000 -0500
+@@ -61,7 +61,7 @@
+ #	if you get setcgtty() warnings during execution, you are feeding gcc
+ #		a non-ANSI <sys/ioctl.h> -- either run fixincludes on it or use
+ #		-traditional in CFLAGS
+-# CC = gcc
++CC = gcc
+ #
+ #	For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following:
+ #
+@@ -141,6 +141,15 @@
+ #LINK = gcc
+ #LFLAGS = -Xlinker -soname=_APP_
+ 
++# Compile with PDCurses installed in a separate directory that doesn't
++# conflict with the system curses/ncurses library
++#CFLAGS = -O -I../include -I/usr/local/include/pdcurses
++# Same as above, but for XCurses
++#CFLAGS = -O -DXCURSES -I../include -I/usr/local/include/pdcurses
++# Compile against system curses library, such as ncurses
++CFLAGS = -O -I../include
++
++
+ # Only used for the Gnome interface.
+ # When including the Gnome interface, you need to include gnome specific
+ # directories.  The ones given below is the usual spot for linux systems.
+@@ -151,8 +160,8 @@
+ # flags for debugging:
+ # CFLAGS = -g -I../include
+ 
+-CFLAGS = -O -I../include
+-LFLAGS = 
++#CFLAGS = -O -I../include
++#LFLAGS = 
+ 
+ # The Qt and Be window systems are written in C++, while the rest of
+ # NetHack is standard C.  If using Qt, uncomment the LINK line here to get
+@@ -174,6 +183,14 @@
+ 	../win/tty/wintty.c
+ WINTTYOBJ = getline.o termcap.o topl.o wintty.o
+ #
++# Files for curses interface
++WINCURSESSRC = ../win/curses/cursmain.c ../win/curses/curswins.c \
++	../win/curses/cursmisc.c ../win/curses/cursdial.c \
++	../win/curses/cursstat.c ../win/curses/cursinit.c \
++	../win/curses/cursmesg.c
++WINCURSESOBJ = cursmain.o curswins.o cursmisc.o cursdial.o cursstat.o \
++	cursinit.o cursmesg.o
++#
+ # files for an X11 port
+ # (tile.c is a generated source file)
+ WINX11SRC = ../win/X11/Window.c ../win/X11/dialogs.c ../win/X11/winX.c \
+@@ -214,8 +231,8 @@
+ 
+ #
+ #
+-WINSRC = $(WINTTYSRC)
+-WINOBJ = $(WINTTYOBJ)
++WINSRC = $(WINCURSESSRC)
++WINOBJ = $(WINCURSESOBJ)
+ 
+ # on some systems the termcap library is in -ltermcap or -lcurses
+ # on 386 Xenix, the -ltermlib tputs() seems not to work; use -lcurses instead
+@@ -231,8 +248,15 @@
+ # WINTTYLIB = -lcurses
+ # WINTTYLIB = -lcurses16
+ # WINTTYLIB = -lncurses
+-WINTTYLIB = -ltermlib
++# WINTTYLIB = -ltermlib
+ #
++# libraries for curses port
++# link with ncurses
++WINCURSESLIB = -lncurses
++# link with pdcurses for SDL, installed in a separate directory
++#WINCURSESLIB = -L/usr/local/lib/pdcurses -lpdcurses -lSDL
++# same as above, for XCurses
++#WINCURSESLIB = -L/usr/local/lib/pdcurses -lXCurses -lXawM -lXmu -lXext -lXt -lX11
+ # libraries for X11
+ # If USE_XPM is defined in config.h, you will also need -lXpm here.
+ WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
+@@ -255,7 +279,7 @@
+ # libraries for BeOS 
+ WINBELIB = -lbe
+ 
+-WINLIB = $(WINTTYLIB)
++WINLIB = $(WINCURSESLIB)
+ 
+ # any other strange libraries your system needs (for Sysunix only -- the more
+ # specialized targets should already be right)
+@@ -605,6 +629,26 @@
+ wintty.o: ../win/tty/wintty.c $(HACK_H) ../include/dlb.h \
+ 		../include/patchlevel.h ../include/tcap.h
+ 	$(CC) $(CFLAGS) -c ../win/tty/wintty.c
++cursmain.o: ../win/curses/cursmain.c $(HACK_H) ../include/wincurs.h
++	$(CC) $(CFLAGS) -c ../win/curses/cursmain.c
++curswins.o: ../win/curses/curswins.c $(HACK_H) ../include/func_tab.h \
++		../include/wincurs.h ../win/curses/curswins.h
++	$(CC) $(CFLAGS) -c ../win/curses/curswins.c
++cursmisc.o: ../win/curses/cursmisc.c $(HACK_H) ../include/wincurs.h \
++		../win/curses/cursmisc.h
++	$(CC) $(CFLAGS) -c ../win/curses/cursmisc.c
++cursdial.o: ../win/curses/cursdial.c $(HACK_H) ../include/func_tab.h \
++		../include/wincurs.h ../win/curses/cursdial.h
++	$(CC) $(CFLAGS) -c ../win/curses/cursdial.c
++cursstat.o: ../win/curses/cursstat.c $(HACK_H) ../include/wincurs.h \
++		../win/curses/cursstat.h
++	$(CC) $(CFLAGS) -c ../win/curses/cursstat.c
++cursinit.o: ../win/curses/cursinit.c $(HACK_H) ../include/wincurs.h \
++		../win/curses/cursinit.h
++	$(CC) $(CFLAGS) -c ../win/curses/cursinit.c
++cursmesg.o: ../win/curses/cursmesg.c $(HACK_H) ../include/wincurs.h \
++		../win/curses/cursmesg.h
++	$(CC) $(CFLAGS) -c ../win/curses/cursmesg.c
+ Window.o: ../win/X11/Window.c ../include/xwindowp.h ../include/xwindow.h \
+ 		$(CONFIG_H)
+ 	$(CC) $(CFLAGS) -c ../win/X11/Window.c
+diff -burN nethack-3.4.3/sys/winnt/cursmake.gcc nethack/sys/winnt/cursmake.gcc
+--- nethack-3.4.3/sys/winnt/cursmake.gcc	1969-12-31 19:00:00.000000000 -0500
++++ nethack/sys/winnt/cursmake.gcc	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,1357 @@
++#   SCCS Id: @(#)Makefile.gcc       3.4     $Date: 2003/11/16 04:50:57 $
++#   Copyright (c) NetHack PC Development Team 1993-2003
++#
++#   NetHack 3.4.x Makefile for MinGW
++#
++#   Win32 Compilers Tested:
++#                  - MinGW 1.0 (gcc version 2.95.3-6) (Console NetHack only)
++#                  - MinGW 2.0 (gcc version 3.2)
++#
++#   If you don't have this compiler, you can get it at:
++#       http://www.mingw.org/
++#
++#   This is used for building two versions of NetHack:
++#   A tty port utilizing the Win32 Console I/O subsystem, Console
++#       NetHack;
++#   A Win32 native port built on the Windows API, Graphical NetHack or
++#       NetHackW.
++#
++#   In addition to your C compiler,
++#
++#     if you want to change     you will need a
++#     files with suffix         workalike for
++#         .y                     yacc   (such as bison)
++#         .l                     lex    (such as flex)
++#
++#
++#   If you have any questions read the sys/winnt/Install.nt file included
++#   with the distribution.
++#
++#   --
++#   Dion Nicolaas
++#==============================================================================
++# Graphical interface
++# Set to Y for a graphical version
++# Set to anything else (or undefine) for a tty version
++
++GRAPHICAL = N
++
++# Debug
++# Set to Y for Debug support (to produce debug information)
++# Set to anything else (or undefine) for a "release" version
++# You can set your debug options below.
++
++DEBUG = Y
++
++cc     = gcc
++rc     = windres
++link   = gcc
++
++cflags = -mms-bitfields
++lflags  = 
++ifeq  "$(DEBUG)" "Y"
++cdebug = -g
++linkdebug = -g
++else
++cdebug =
++linkdebug =
++endif
++
++#
++#  Set the gamedir according to your preference.
++#  If not present prior to compilation it gets created.
++
++ifeq  "$(GRAPHICAL)" "Y"
++# Game Name
++GAME    = NetHackW
++else
++# Game Name
++GAME    = NetHackC
++endif
++# Game directory
++GAMEDIR = ../binary
++
++#
++#  Source directories.    Makedefs hardcodes these, don't change them.
++#
++
++# NetHack include files
++INCL  = ../include
++# NetHack data files
++DAT   = ../dat
++# NetHack documentation files
++DOC   = ../doc
++# Utility source
++UTIL  = ../util
++# Main source
++SRC   = ../src
++# Shared system files
++SSYS  = ../sys/share
++# NT Win32 specific files
++NTSYS = ../sys/winnt
++# window port files (tty)
++#TTY   = ../win/tty
++TTY   = ../win/curses
++# window port files (Win32)
++WIN32 = ../win/win32
++# Tile support files
++WSHR  = ../win/share
++
++#
++#  Object directory.
++#
++
++OBJ = o
++
++
++#
++#==========================================
++# Exe File Info.
++#==========================================
++
++# Yacc/Lex ... if you got 'em.
++#
++# If you have yacc and lex programs (or work-alike such as bison
++# and flex), comment out the upper two macros and uncomment
++# the lower two.
++#
++
++DO_YACC = YACC_MSG
++DO_LEX  = LEX_MSG
++#DO_YACC  = YACC_ACT
++#DO_LEX   = LEX_ACT
++
++# - Specify your yacc and lex programs (or work-alikes) here.
++
++#YACC   = bison -y
++YACC   = byacc
++#YACC   = yacc
++
++#LEX    = lex
++LEX     = flex
++
++#
++# - Specify your flex skeleton file (if needed).
++#
++
++FLEXSKEL =
++#FLEXSKEL = -S../tools/flex.ske
++
++YTABC   = y_tab.c
++YTABH   = y_tab.h
++LEXYYC  = lexyy.c
++
++#
++# Optional high-quality BSD random number generation routines
++# (see pcconf.h). Set to nothing if not used.
++#
++
++RANDOM  = $(OBJ)/random.o
++#RANDOM =
++
++#===============================================
++#======= End of Modification Section ===========
++#===============================================
++################################################
++#                                              #
++# Nothing below here should have to be changed.#
++#                                              #
++################################################
++
++ifeq  "$(GRAPHICAL)" "Y"
++WINPORT  = $(O)tile.o $(O)mhaskyn.o $(O)mhdlg.o \
++	$(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \
++	$(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o $(O)mhsplash.o \
++	$(O)mhstatus.o $(O)mhtext.o $(O)mswproc.o $(O)winhack.o
++WINPFLAG   = -DTILES -DMSWIN_GRAPHICS -D_WIN32_IE=0x0400
++NHRES   = $(O)winres.o
++WINPINC = -I$(WIN32)
++WINPHDR = $(WIN32)/mhaskyn.h $(WIN32)/mhdlg.h $(WIN32)/mhfont.h \
++	$(WIN32)/mhinput.h $(WIN32)/mhmain.h $(WIN32)/mhmap.h \
++	$(WIN32)/mhmenu.h $(WIN32)/mhmsg.h $(WIN32)/mhmsgwnd.h \
++	$(WIN32)/mhrip.h $(WIN32)/mhstatus.h \
++	$(WIN32)/mhtext.h $(WIN32)/resource.h $(WIN32)/winMS.h
++WINPLIBS =  -lcomctl32 -lwinmm
++else
++WINPORT = $(O)nttty.o
++#WINPFLAG= -DWIN32CON
++WINPHDR =
++NHRES   = $(O)console.o
++WINPINC =
++#WINPLIBS = ../lib/pdcurses.a -lwinmm
++WINPLIBS = ../lib/libpdcurses.a ../lib/libSDL.a -lwinmm
++endif
++
++TILEUTIL16  = $(UTIL)/tile2bmp.exe
++TILEBMP16   = $(SRC)/tiles.bmp
++
++TILEUTIL32  = $(UTIL)/til2bm32.exe
++TILEBMP32   = $(SRC)/tiles32.bmp
++
++SOUND = $(OBJ)/ntsound.o
++
++#SOUND =
++
++# To store all the level files,
++# help files, etc. in a single library file.
++# USE_DLB = Y is left uncommented
++
++USE_DLB = Y
++
++ifeq  "$(USE_DLB)" "Y"
++DLBFLG = -DDLB
++else
++DLBFLG =
++endif
++
++#==========================================
++# Setting up the compiler and linker
++# macros. All builds include the base ones.
++#==========================================
++
++CFLAGSBASE  = -c $(cflags) -I$(INCL) $(WINPINC) $(cdebug)
++LFLAGSBASEC = $(linkdebug) -mwindows
++LFLAGSBASEG = $(linkdebug) -mwindows
++
++#==========================================
++# Util builds
++#==========================================
++
++CFLAGSU = $(CFLAGSBASE) $(WINPFLAG)
++LFLAGSU = $(LFLAGSBASEC)
++
++#==========================================
++# - Game build
++#==========================================
++
++CFLAGS   = $(CFLAGSBASE) $(WINPFLAG) $(DLBFLG)
++lflags  = $(LFLAGSBASE)
++ifeq "$(GRAPHICAL)" "Y"
++lflags  = $(LFLAGSBASEG)
++else
++lflags  = $(LFLAGSBASEC)
++endif
++
++GAMEFILE = $(GAMEDIR)/$(GAME).exe # whole thing
++
++ifeq  "$(USE_DLB)" "Y"
++DLB = nhdat
++else
++DLB =
++endif
++
++#==========================================
++#================ RULES ==================
++#==========================================
++
++.SUFFIXES: .exe .o .til .uu .c .y .l
++
++#==========================================
++# Rules for files in src
++#==========================================
++
++$(OBJ)/%.o : /%.c
++	$(cc) $(CFLAGS)  -o$@ $<
++
++$(OBJ)/%.o : $(SRC)/%.c
++	$(cc) $(CFLAGS)   -o$@  $<
++
++#==========================================
++# Rules for files in sys/share
++#==========================================
++
++$(OBJ)/%.o : $(SSYS)/%.c
++	$(cc) $(CFLAGS)  -o$@  $<
++
++#==========================================
++# Rules for files in sys/winnt
++#==========================================
++
++$(OBJ)/%.o : $(NTSYS)/%.c
++	$(cc) $(CFLAGS)  -o$@  $<
++
++$(INCL)/%.h : $(NTSYS)/%.h
++	@copy $< $@
++
++#==========================================
++# Rules for files in util
++#==========================================
++
++$(OBJ)/%.o : $(UTIL)/%.c
++	$(cc) $(CFLAGSU) -o$@ $<
++
++#==========================================
++# Rules for files in win/share
++#==========================================
++
++$(OBJ)/%.o : $(WSHR)/%.c
++	$(cc) $(CFLAGS)  -o$@ $<
++
++$(INCL)/%.h : $(WSHR)/%.h
++	@copy $< $@
++
++#{$(WSHR)}.txt{$(DAT)}.txt:
++#	@copy $< $@
++
++#==========================================
++# Rules for files in win/tty
++#==========================================
++
++$(OBJ)/%.o : $(TTY)/%.c
++	$(cc) $(CFLAGS)  -o$@  $<
++
++#==========================================
++# Rules for files in win/win32
++#==========================================
++
++$(OBJ)/%.o : $(WIN32)/%.c
++	$(cc) $(CFLAGS)  -o$@  $<
++
++#==========================================
++#================ MACROS ==================
++#==========================================
++# This section creates shorthand macros for many objects
++# referenced later on in the Makefile.
++#
++
++DEFFILE = $(NTSYS)/$(GAME).def
++
++#
++# Shorten up the location for some files
++#
++
++O  = $(OBJ)/
++
++U  = $(UTIL)/
++
++#
++# Utility Objects.
++#
++
++MAKESRC        = $(U)makedefs.c
++
++SPLEVSRC       = $(U)lev_yacc.c  $(U)lev_$(LEX).c $(U)lev_main.c  $(U)panic.c
++
++DGNCOMPSRC     = $(U)dgn_yacc.c  $(U)dgn_$(LEX).c $(U)dgn_main.c
++
++MAKEOBJS       = $(O)makedefs.o $(O)monst.o $(O)objects.o
++
++SPLEVOBJS      = $(O)lev_yacc.o  $(O)lev_$(LEX).o $(O)lev_main.o \
++	$(O)alloc.o   $(O)decl.o      $(O)drawing.o \
++	$(O)monst.o   $(O)objects.o   $(O)panic.o
++
++DGNCOMPOBJS    = $(O)dgn_yacc.o  $(O)dgn_$(LEX).o $(O)dgn_main.o \
++	$(O)alloc.o   $(O)panic.o
++
++RECOVOBJS      = $(O)recover.o
++
++TILEFILES      = $(WSHR)/monsters.txt $(WSHR)/objects.txt $(WSHR)/other.txt
++
++#
++# These are not invoked during a normal game build in 3.4
++#
++TEXT_IO        = $(O)tiletext.o  $(O)tiletxt.o   $(O)drawing.o \
++	$(O)decl.o    $(O)monst.o     $(O)objects.o
++
++TEXT_IO32      = $(O)tilete32.o $(O)tiletx32.o $(O)drawing.o \
++	$(O)decl.o    $(O)monst.o     $(O)objects.o
++
++GIFREADERS     = $(O)gifread.o   $(O)alloc.o $(O)panic.o
++GIFREADERS32   = $(O)gifrd32.o $(O)alloc.o $(O)panic.o
++
++PPMWRITERS     = $(O)ppmwrite.o $(O)alloc.o $(O)panic.o
++
++#
++#  Object files for the game itself.
++#
++
++VOBJ01 = $(O)allmain.o  $(O)alloc.o    $(O)apply.o    $(O)artifact.o
++VOBJ02 = $(O)attrib.o   $(O)ball.o     $(O)bones.o    $(O)botl.o
++VOBJ03 = $(O)cmd.o      $(O)dbridge.o  $(O)decl.o     $(O)detect.o
++VOBJ04 = $(O)dig.o      $(O)display.o  $(O)do.o       $(O)do_name.o
++VOBJ05 = $(O)do_wear.o  $(O)dog.o      $(O)dogmove.o  $(O)dokick.o
++VOBJ06 = $(O)dothrow.o  $(O)drawing.o  $(O)dungeon.o  $(O)eat.o
++VOBJ07 = $(O)end.o      $(O)engrave.o  $(O)exper.o    $(O)explode.o
++VOBJ08 = $(O)extralev.o $(O)files.o    $(O)fountain.o $(O)hack.o
++VOBJ09 = $(O)hacklib.o  $(O)invent.o   $(O)light.o    $(O)lock.o
++VOBJ10 = $(O)mail.o     $(O)makemon.o  $(O)mapglyph.o $(O)mcastu.o
++VOBJ11 = $(O)mhitm.o    $(O)mhitu.o    $(O)minion.o   $(O)mklev.o
++VOBJ12 = $(O)mkmap.o    $(O)mkmaze.o   $(O)mkobj.o    $(O)mkroom.o
++VOBJ13 = $(O)mon.o      $(O)mondata.o  $(O)monmove.o  $(O)monst.o
++VOBJ14 = $(O)monstr.o   $(O)mplayer.o  $(O)mthrowu.o  $(O)muse.o
++VOBJ15 = $(O)music.o    $(O)o_init.o   $(O)objects.o  $(O)objnam.o
++VOBJ16 = $(O)options.o  $(O)pager.o    $(O)pickup.o   $(O)pline.o
++VOBJ17 = $(O)polyself.o $(O)potion.o   $(O)pray.o     $(O)priest.o
++VOBJ18 = $(O)quest.o    $(O)questpgr.o $(RANDOM)      $(O)read.o
++VOBJ19 = $(O)rect.o     $(O)region.o   $(O)restore.o  $(O)rip.o
++VOBJ20 = $(O)rnd.o      $(O)role.o     $(O)rumors.o   $(O)save.o
++VOBJ21 = $(O)shk.o      $(O)shknam.o   $(O)sit.o      $(O)sounds.o
++VOBJ22 = $(O)sp_lev.o   $(O)spell.o    $(O)steal.o    $(O)steed.o
++VOBJ23 = $(O)teleport.o $(O)timeout.o  $(O)topten.o   $(O)track.o
++VOBJ24 = $(O)trap.o     $(O)u_init.o   $(O)uhitm.o    $(O)vault.o
++VOBJ25 = $(O)vis_tab.o  $(O)vision.o   $(O)weapon.o   $(O)were.o
++VOBJ26 = $(O)wield.o    $(O)windows.o  $(O)wizard.o   $(O)worm.o
++VOBJ27 = $(O)worn.o     $(O)write.o    $(O)zap.o
++
++DLBOBJ = $(O)dlb.o
++
++#TTYOBJ = $(O)topl.o     $(O)getline.o  $(O)wintty.o
++TTYOBJ = $(O)cursmain.o $(O)curswins.o  $(O)cursmisc.o $(O)cursdial.o \
++	$(O)cursstat.o $(O)cursinit.o $(O)cursmesg.o 
++
++SOBJ   = $(O)winnt.o    $(O)pcsys.o      $(O)pcunix.o  \
++	$(SOUND) $(O)pcmain.o $(O)mapimail.o $(O)nhlan.o
++
++OBJS   = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
++	$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
++	$(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \
++	$(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \
++	$(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
++	$(VOBJ26) $(VOBJ27)
++
++WINPOBJ = $(WINPORT)
++
++VVOBJ  = $(O)version.o
++
++ALLOBJ  = $(WINPOBJ) $(SOBJ) $(DLBOBJ)  $(TTYOBJ) $(WOBJ) $(OBJS) $(VVOBJ)
++
++ifeq "$(GRAPHICAL)" "Y"
++OPTIONS_FILE = $(DAT)/guioptions
++else
++OPTIONS_FILE = $(DAT)/ttyoptions
++endif
++
++#==========================================
++# Header file macros
++#==========================================
++
++CONFIG_H = $(INCL)/config.h $(INCL)/config1.h $(INCL)/tradstdc.h \
++	       $(INCL)/global.h $(INCL)/coord.h $(INCL)/vmsconf.h \
++	       $(INCL)/system.h $(INCL)/unixconf.h $(INCL)/os2conf.h \
++	       $(INCL)/micro.h $(INCL)/pcconf.h $(INCL)/tosconf.h \
++	       $(INCL)/amiconf.h $(INCL)/macconf.h $(INCL)/beconf.h \
++	       $(INCL)/ntconf.h $(INCL)/nhlan.h
++
++HACK_H = $(INCL)/hack.h $(CONFIG_H) $(INCL)/align.h \
++	       $(INCL)/dungeon.h $(INCL)/monsym.h $(INCL)/mkroom.h \
++	       $(INCL)/objclass.h $(INCL)/youprop.h $(INCL)/prop.h \
++	       $(INCL)/permonst.h $(INCL)/monattk.h \
++	       $(INCL)/monflag.h $(INCL)/mondata.h $(INCL)/pm.h \
++	       $(INCL)/wintype.h $(INCL)/decl.h $(INCL)/quest.h \
++	       $(INCL)/spell.h $(INCL)/color.h $(INCL)/obj.h \
++	       $(INCL)/you.h $(INCL)/attrib.h $(INCL)/monst.h \
++	       $(INCL)/skills.h $(INCL)/onames.h $(INCL)/timeout.h \
++	       $(INCL)/trap.h $(INCL)/flag.h $(INCL)/rm.h \
++	       $(INCL)/vision.h $(INCL)/display.h $(INCL)/engrave.h \
++	       $(INCL)/rect.h $(INCL)/region.h $(INCL)/winprocs.h \
++	       $(INCL)/wintty.h $(INCL)/trampoli.h
++
++LEV_H       = $(INCL)/lev.h
++DGN_FILE_H  = $(INCL)/dgn_file.h
++LEV_COMP_H  = $(INCL)/lev_comp.h
++SP_LEV_H    = $(INCL)/sp_lev.h
++TILE_H      = ../win/share/tile.h
++
++#==========================================
++# Miscellaneous
++#==========================================
++
++DATABASE = $(DAT)/data.base
++
++#
++#  The name of the game.
++#
++
++GAMEFILE = $(GAMEDIR)/$(GAME).exe
++
++
++#==========================================
++#=============== TARGETS ==================
++#==========================================
++
++# Since DOS doesn't allow / as path separator, and GCC doesn't allow \ as
++# path separator, we must change all pathnames when performing DOS commands.
++# This is done by blindly applying $(subst /,\, ...) on every command.
++# Where any command contain / for another reason (switch char, or echoing
++# comment lines to lev/dungeon files) a little more care is taken.
++
++#
++#  The default make target (so just typing 'nmake' is useful).
++#
++default : $(GAMEFILE)
++
++#
++#  The main target.
++#
++
++$(GAME) : $(O)obj.tag $(O)utility.tag graphicschk $(GAMEFILE)
++	@echo $(GAME) is up to date.
++
++#
++#  Everything
++#
++
++all :   install
++
++install: graphicschk $(GAME) $(O)install.tag
++	@echo Done.
++
++
++$(O)install.tag:  $(DAT)/data    $(DAT)/rumors    $(DAT)/dungeon \
++	       $(DAT)/oracles $(DAT)/quest.dat $(O)sp_lev.tag $(DLB)
++ifeq  "$(USE_DLB)" "Y"
++	$(subst /,\,copy nhdat                $(GAMEDIR))
++	$(subst /,\,copy $(DAT)/license       $(GAMEDIR))
++	$(subst /,\,copy $(DAT)/opthelp       $(GAMEDIR))
++else
++	$(subst /,\,copy $(DAT)/*.            $(GAMEDIR))
++	$(subst /,\,copy $(DAT)/*.dat         $(GAMEDIR))
++	$(subst /,\,copy $(DAT)/*.lev         $(GAMEDIR))
++	$(subst /,\,if exist $(GAMEDIR)/makefile del $(GAMEDIR)/makefile)
++endif
++	$(subst /,\,if exist $(DOC)/guidebook.txt copy $(DOC)/guidebook.txt $(GAMEDIR)/Guidebook.txt)
++	$(subst /,\,if exist $(DOC)/nethack.txt copy $(DOC)/nethack.txt $(GAMEDIR)/NetHack.txt)
++	$(subst /,\,copy $(NTSYS)/defaults.nh   $(GAMEDIR)/defaults.nh)
++	$(subst /,\,echo install done > $@)
++
++#  copy $(NTSYS)/winnt.hlp    $(GAMEDIR)
++
++recover: $(U)recover.exe
++	$(subst /,\,if exist $(U)recover.exe copy $(U)recover.exe  $(GAMEDIR))
++	$(subst /,\,if exist $(DOC)/recover.txt copy $(DOC)/recover.txt $(GAMEDIR)/recover.txt)
++
++$(O)sp_lev.tag: $(O)utility.tag $(DAT)/bigroom.des  $(DAT)/castle.des \
++	 $(DAT)/endgame.des $(DAT)/gehennom.des $(DAT)/knox.des   \
++	 $(DAT)/medusa.des  $(DAT)/oracle.des   $(DAT)/tower.des  \
++	 $(DAT)/yendor.des  $(DAT)/arch.des     $(DAT)/barb.des   \
++	 $(DAT)/caveman.des $(DAT)/healer.des   $(DAT)/knight.des \
++	 $(DAT)/monk.des    $(DAT)/priest.des   $(DAT)/ranger.des \
++	 $(DAT)/rogue.des   $(DAT)/samurai.des  $(DAT)/sokoban.des \
++	 $(DAT)/tourist.des $(DAT)/valkyrie.des $(DAT)/wizard.des
++	$(subst /,\,$(U)lev_comp $(DAT)/bigroom.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/castle.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/endgame.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/gehennom.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/knox.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/mines.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/medusa.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/oracle.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/sokoban.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/tower.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/yendor.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/arch.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/barb.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/caveman.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/healer.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/knight.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/monk.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/priest.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/ranger.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/rogue.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/samurai.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/tourist.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/valkyrie.des)
++	$(subst /,\,$(U)lev_comp $(DAT)/wizard.des)
++	$(subst /,\,copy *.lev $(DAT))
++	$(subst /,\,del *.lev)
++	$(subst /,\,echo sp_levs done > $(O)sp_lev.tag)
++
++$(O)utility.tag: $(INCL)/date.h $(INCL)/onames.h $(INCL)/pm.h \
++	 $(SRC)/monstr.c $(SRC)/vis_tab.c $(U)lev_comp.exe $(INCL)/vis_tab.h \
++	 $(U)dgn_comp.exe $(TILEUTIL16)
++	$(subst /,\,@echo utilities made >$@)
++	@echo utilities made.
++
++tileutil: $(U)gif2txt.exe $(U)gif2tx32.exe $(U)txt2ppm.exe
++	@echo Optional tile development utilities are up to date.
++
++ifeq  "$(GRAPHICAL)" "Y"
++$(NHRES): $(TILEBMP16) $(WIN32)/winhack.rc $(WIN32)/mnsel.bmp \
++	 $(WIN32)/mnselcnt.bmp $(WIN32)/mnunsel.bmp \
++	 $(WIN32)/petmark.bmp $(WIN32)/NetHack.ico $(WIN32)/rip.bmp \
++	 $(WIN32)/splash.bmp
++	@$(rc) -o$@ --include-dir $(WIN32) -i $(WIN32)/winhack.rc
++else
++$(NHRES): $(NTSYS)/console.rc $(NTSYS)/NetHack.ico 
++	@$(rc) -o$@ --include-dir $(NTSYS) -i $(NTSYS)/console.rc
++endif
++
++#==========================================
++#  The main target.
++#==========================================
++$(O)gamedir.tag:
++	$(subst /,\,@if not exist $(GAMEDIR)/*.* echo creating directory $(GAMEDIR))
++	$(subst /,\,@if not exist $(GAMEDIR)/*.* mkdir $(GAMEDIR))
++	$(subst /,\,@echo directory created > $@)
++
++ifeq  "$(GRAPHICAL)" "Y"
++$(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag
++else
++#$(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag \
++#	 $(GAMEDIR)/nhdefkey.dll $(GAMEDIR)/nh340key.dll $(GAMEDIR)/nhraykey.dll
++$(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag
++endif
++	@echo Linking....
++	$(link) $(lflags) -o$@ $(ALLOBJ) $(NHRES) $(WINPLIBS)
++	$(subst /,\,@if exist $(O)install.tag del $(O)install.tag)
++
++
++$(O)nhdefkey.o:
++	$(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(NTSYS)/nhdefkey.c 
++
++$(GAMEDIR)/nhdefkey.dll : $(O)nhdefkey.o $(O)gamedir.tag
++	@echo Linking $@
++	$(cc) -shared -Wl,--export-all-symbols \
++		-Wl,--add-stdcall-alias -o $@ $<
++
++$(O)nh340key.o:
++	$(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(NTSYS)/nh340key.c 
++
++$(GAMEDIR)/nh340key.dll : $(O)nh340key.o $(O)gamedir.tag
++	@echo Linking $@
++	$(cc) -shared -Wl,--export-all-symbols \
++		-Wl,--add-stdcall-alias -o $@ $<
++
++$(O)nhraykey.o:
++		$(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(NTSYS)/nhraykey.c 
++
++$(GAMEDIR)/nhraykey.dll : $(O)nhraykey.o $(O)gamedir.tag
++	@echo Linking $@
++	$(cc) -shared -Wl,--export-all-symbols \
++		-Wl,--add-stdcall-alias -o $@ $<
++
++$(GAME)_.ico : $(NTSYS)/$(GAME).ico
++	$(subst /,\,@copy $(NTSYS)/$(GAME).ico $@)
++
++#==========================================
++# Create directory for holding object files
++#==========================================
++
++graphicschk:
++ifeq  "$(GRAPHICAL)" "Y"
++	@echo ----
++	@echo NOTE: This build will include tile support.
++	@echo ----
++endif
++	$(subst /,\,@echo graphicschk > graphicschk)
++
++#
++#  Secondary Targets.
++#
++
++#==========================================
++# Makedefs Stuff
++#==========================================
++
++$(U)makedefs.exe: $(MAKEOBJS)
++	@$(link) $(LFLAGSU) -o$@ $(MAKEOBJS)
++
++$(O)makedefs.o: $(CONFIG_H) $(INCL)/monattk.h $(INCL)/monflag.h \
++	 $(INCL)/objclass.h $(INCL)/monsym.h $(INCL)/qtext.h \
++	 $(INCL)/patchlevel.h $(U)makedefs.c $(O)obj.tag
++	$(cc) $(CFLAGSU) -o$@ $(U)makedefs.c
++
++#
++#  date.h should be remade every time any of the source or include
++#  files is modified.
++#
++
++$(INCL)/date.h $(OPTIONS_FILE): $(U)makedefs.exe
++	$(subst /,\,$(U)makedefs -v)
++
++#$(OPTIONS_FILE): $(U)makedefs.exe
++#	$(subst /,\,$(U)makedefs -v)
++
++$(INCL)/onames.h : $(U)makedefs.exe
++	$(subst /,\,$(U)makedefs -o)
++
++$(INCL)/pm.h : $(U)makedefs.exe
++	$(subst /,\,$(U)makedefs -p)
++
++#$(INCL)/trap.h : $(U)makedefs.exe
++#  $(U)makedefs -t
++
++$(SRC)/monstr.c: $(U)makedefs.exe
++	$(subst /,\,$(U)makedefs -m)
++
++$(INCL)/vis_tab.h: $(U)makedefs.exe
++	$(subst /,\,$(U)makedefs -z)
++
++$(SRC)/vis_tab.c: $(U)makedefs.exe
++	$(subst /,\,$(U)makedefs -z)
++
++#==========================================
++# uudecode utility and uuencoded targets
++#==========================================
++
++$(U)uudecode.exe: $(O)uudecode.o
++	@$(link) $(LFLAGSU) -o$@ $(O)uudecode.o
++
++$(O)uudecode.o: $(SSYS)/uudecode.c
++
++$(NTSYS)/NetHack.ico : $(U)uudecode.exe $(NTSYS)/nhico.uu
++	$(subst /,\,$(U)uudecode.exe $(NTSYS)/nhico.uu)
++	$(subst /,\,copy NetHack.ico $@)
++	del NetHack.ico
++
++$(WIN32)/NetHack.ico : $(NTSYS)/NetHack.ico
++	$(subst /,\,copy $< $@)
++
++$(WIN32)/mnsel.bmp: $(U)uudecode.exe $(WIN32)/mnsel.uu
++	$(subst /,\,$(U)uudecode.exe $(WIN32)/mnsel.uu)
++	$(subst /,\,copy mnsel.bmp $@)
++	del mnsel.bmp
++
++$(WIN32)/mnselcnt.bmp: $(U)uudecode.exe $(WIN32)/mnselcnt.uu
++	$(subst /,\,$(U)uudecode.exe $(WIN32)/mnselcnt.uu)
++	$(subst /,\,copy mnselcnt.bmp $@)
++	del mnselcnt.bmp
++
++$(WIN32)/mnunsel.bmp: $(U)uudecode.exe $(WIN32)/mnunsel.uu
++	$(subst /,\,$(U)uudecode.exe $(WIN32)/mnunsel.uu)
++	$(subst /,\,copy mnunsel.bmp $@)
++	del mnunsel.bmp
++
++$(WIN32)/petmark.bmp: $(U)uudecode.exe $(WIN32)/petmark.uu
++	$(subst /,\,$(U)uudecode.exe $(WIN32)/petmark.uu)
++	$(subst /,\,copy petmark.bmp $@)
++	del petmark.bmp
++
++$(WIN32)/rip.bmp: $(U)uudecode.exe $(WIN32)/rip.uu
++	$(subst /,\,$(U)uudecode.exe $(WIN32)/rip.uu)
++	$(subst /,\,copy rip.bmp $@)
++	del rip.bmp
++
++$(WIN32)/splash.bmp: $(U)uudecode.exe $(WIN32)/splash.uu
++	$(subst /,\,$(U)uudecode.exe $(WIN32)/splash.uu)
++	$(subst /,\,copy splash.bmp $@)
++	del splash.bmp
++
++
++#==========================================
++# Level Compiler Stuff
++#==========================================
++
++LEVCFLAGS=$(cflags) -c -DWIN32 -D_WIN32 -I../include $(cdebug) -DDLB
++
++$(U)lev_comp.exe: $(SPLEVOBJS)
++	@echo Linking $@...
++	@$(link) $(LFLAGSU) -o$@ $(SPLEVOBJS)
++
++$(O)lev_yacc.o: $(HACK_H)   $(SP_LEV_H) $(INCL)/lev_comp.h $(U)lev_yacc.c
++	$(cc) $(LEVCFLAGS) -o$@ $(U)lev_yacc.c
++
++$(O)lev_$(LEX).o: $(HACK_H)   $(INCL)/lev_comp.h $(SP_LEV_H) \
++	$(U)lev_$(LEX).c
++	$(cc) $(LEVCFLAGS) -o$@ $(U)lev_$(LEX).c
++
++$(O)lev_main.o:   $(U)lev_main.c $(HACK_H)   $(SP_LEV_H)
++	$(cc) $(LEVCFLAGS) -o$@ $(U)lev_main.c
++
++
++$(U)lev_yacc.c $(INCL)/lev_comp.h : $(U)lev_comp.y
++ifeq  "$(DO_YACC)" "YACC_ACT"
++	$(subst /,\,$(YACC) -d $(U)lev_comp.y)
++	$(subst /,\,copy $(YTABC) $(U)lev_yacc.c)
++	$(subst /,\,copy $(YTABH) $(INCL)/lev_comp.h)
++	$(subst /,\,@del $(YTABC))
++	$(subst /,\,@del $(YTABH))
++
++else
++	@echo $(U)lev_comp.y has changed.
++	@echo To update $(U)lev_yacc.c and $(INCL)/lev_comp.h run $(YACC).
++	@echo ---
++	@echo For now, we will copy the prebuilt lev_yacc.c and
++	@echo lev_comp.h from $(SSYS) into $(UTIL) and use them.
++	$(subst /,\,@copy $(SSYS)/lev_yacc.c $(U)lev_yacc.c >nul)
++	$(subst /,\,@copy $(SSYS)/lev_comp.h $(INCL)/lev_comp.h >nul)
++	$(subst /,\,echo.>>$(U)lev_yacc.c)
++	$(subst /,\,echo.>>$(INCL)/lev_comp.h)
++endif
++
++$(U)lev_$(LEX).c: $(U)lev_comp.l
++ifeq  "$(DO_LEX)" "LEX_ACT"
++	$(subst /,\,$(LEX) $(FLEXSKEL) $(U)lev_comp.l)
++	$(subst /,\,copy $(LEXYYC) $@)
++	$(subst /,\,@del $(LEXYYC))
++else
++	@echo $(U)lev_comp.l has changed. To update $@ run $(LEX).
++	@echo ---
++	@echo For now, we will copy the prebuilt lev_lex.c
++	@echo from $(SSYS) into $(UTIL) and use it.
++	$(subst /,\,@copy $(SSYS)/lev_lex.c $@ >nul)
++	$(subst /,\,echo.>>$@)
++endif
++
++#==========================================
++# Dungeon Compiler Stuff
++#==========================================
++
++$(U)dgn_comp.exe: $(DGNCOMPOBJS)
++	@echo Linking $@...
++	@$(link) $(LFLAGSU) -o$@ $(DGNCOMPOBJS)
++
++
++$(O)dgn_yacc.o:   $(HACK_H)   $(DGN_FILE_H) $(INCL)/dgn_comp.h $(U)dgn_yacc.c
++	$(cc) $(LEVCFLAGS) -o$@ $(U)dgn_yacc.c
++
++$(O)dgn_$(LEX).o: $(HACK_H)   $(DGN_FILE_H)  $(INCL)/dgn_comp.h \
++	 $(U)dgn_$(LEX).c
++	$(cc) $(LEVCFLAGS) -o$@ $(U)dgn_$(LEX).c
++
++$(O)dgn_main.o:   $(HACK_H) $(U)dgn_main.c
++	$(cc) $(LEVCFLAGS) -o$@ $(U)dgn_main.c
++
++$(U)dgn_yacc.c $(INCL)/dgn_comp.h : $(U)dgn_comp.y
++ifeq  "$(DO_YACC)" "YACC_ACT"
++	$(subst /,\,$(YACC) -d $(U)dgn_comp.y)
++	$(subst /,\,copy $(YTABC) $(U)dgn_yacc.c)
++	$(subst /,\,copy $(YTABH) $(INCL)/dgn_comp.h)
++	$(subst /,\,@del $(YTABC))
++	$(subst /,\,@del $(YTABH))
++else
++	@echo $(U)dgn_comp.y has changed. To update dgn_yacc.c and
++	@echo $(INCL)/dgn_comp.h run $(YACC).
++	@echo ---
++	@echo For now, we will copy the prebuilt $(U)dgn_yacc.c and
++	@echo dgn_comp.h from $(SSYS) into $(UTIL) and use them.
++	$(subst /,\,@copy $(SSYS)/dgn_yacc.c $(U)dgn_yacc.c >nul)
++	$(subst /,\,@copy $(SSYS)/dgn_comp.h $(INCL)/dgn_comp.h >nul)
++	$(subst /,\,echo.>>$(U)dgn_yacc.c)
++	$(subst /,\,echo.>>$(INCL)/dgn_comp.h)
++endif
++
++$(U)dgn_$(LEX).c: $(U)dgn_comp.l
++ifeq  "$(DO_LEX)" "LEX_ACT"
++	$(subst /,\,$(LEX) $(FLEXSKEL) $(U)dgn_comp.l)
++	$(subst /,\,copy $(LEXYYC) $@)
++	$(subst /,\,@del $(LEXYYC))
++else
++	@echo $(U)dgn_comp.l has changed. To update $@ run $(LEX).
++	@echo ---
++	@echo For now, we will copy the prebuilt dgn_lex.c
++	@echo from $(SSYS) into $(UTIL) and use it.
++	$(subst /,\,@copy $(SSYS)/dgn_lex.c $@ >nul)
++	$(subst /,\,echo.>>$@)
++endif
++
++#==========================================
++# Create directory for holding object files
++#==========================================
++
++$(O)obj.tag:
++	$(subst /,\,@if not exist $(OBJ)/*.* echo creating directory $(OBJ))
++	$(subst /,\,@if not exist $(OBJ)/*.* mkdir $(OBJ))
++	$(subst /,\,@echo directory created > $@)
++
++
++#==========================================
++#=========== SECONDARY TARGETS ============
++#==========================================
++
++#===========================================
++# Header files NOT distributed in ../include
++#===========================================
++
++$(INCL)/win32api.h: $(NTSYS)/win32api.h
++	$(subst /,\,copy $(NTSYS)/win32api.h $@)
++
++
++#==========================================
++# DLB utility and nhdat file creation
++#==========================================
++
++$(U)dlb_main.exe: $(DLBOBJ) $(O)dlb.o
++	@$(link) $(LFLAGSU) -o$@ $(O)dlb_main.o $(O)dlb.o $(O)alloc.o $(O)panic.o
++
++
++$(O)dlb.o:   $(O)dlb_main.o $(O)alloc.o $(O)panic.o $(INCL)/dlb.h
++	$(cc) $(CFLAGS) -o$@ $(SRC)/dlb.c
++
++$(O)dlb_main.o: $(UTIL)/dlb_main.c $(INCL)/config.h $(INCL)/dlb.h
++	$(cc) $(CFLAGS) -o$@ $(UTIL)/dlb_main.c
++
++$(DAT)/porthelp: $(NTSYS)/porthelp
++	$(subst /,\,@copy $(NTSYS)/porthelp $@ >nul)
++
++nhdat:  $(U)dlb_main.exe $(DAT)/data $(DAT)/oracles $(OPTIONS_FILE) \
++	 $(DAT)/quest.dat $(DAT)/rumors $(DAT)/help $(DAT)/hh $(DAT)/cmdhelp \
++	 $(DAT)/history $(DAT)/opthelp $(DAT)/wizhelp $(DAT)/dungeon \
++	 $(DAT)/porthelp $(DAT)/license $(O)sp_lev.tag
++	$(subst /,\,echo data >$(DAT)/dlb.lst)
++	$(subst /,\,echo oracles >>$(DAT)/dlb.lst)
++	$(subst /,\,if exist $(DAT)/options echo options >>$(DAT)/dlb.lst)
++	$(subst /,\,if exist $(DAT)/ttyoptions echo ttyoptions >>$(DAT)/dlb.lst)
++	$(subst /,\,if exist $(DAT)/guioptions echo guioptions >>$(DAT)/dlb.lst)
++	$(subst /,\,if exist $(DAT)/porthelp echo porthelp >>$(DAT)/dlb.lst)
++	$(subst /,\,echo quest.dat >>$(DAT)/dlb.lst)
++	$(subst /,\,echo rumors >>$(DAT)/dlb.lst)
++	$(subst /,\,echo help >>$(DAT)/dlb.lst)
++	$(subst /,\,echo hh >>$(DAT)/dlb.lst)
++	$(subst /,\,echo cmdhelp >>$(DAT)/dlb.lst)
++	$(subst /,\,echo history >>$(DAT)/dlb.lst)
++	$(subst /,\,echo opthelp >>$(DAT)/dlb.lst)
++	$(subst /,\,echo wizhelp >>$(DAT)/dlb.lst)
++	$(subst /,\,echo dungeon >>$(DAT)/dlb.lst)
++	$(subst /,\,echo license >>$(DAT)/dlb.lst)
++	dir /l /b /-p $(subst /,\,$(DAT)/*.lev >>$(DAT)/dlb.lst)
++	$(subst /,\,$(U)dlb_main CcIf $(DAT) dlb.lst $(SRC)/nhdat)
++
++#==========================================
++#  Recover Utility
++#==========================================
++
++$(U)recover.exe: $(RECOVOBJS)
++	$(link) $(LFLAGSU) -o$@ $(RECOVOBJS)
++
++$(O)recover.o: $(CONFIG_H) $(U)recover.c $(INCL)/win32api.h
++	$(cc) $(CFLAGSU) -o$@ $(U)recover.c
++
++#==========================================
++#  Tile Mapping
++#==========================================
++
++$(SRC)/tile.c: $(U)tilemap.exe
++	@echo A new $@ has been created
++	@$(U)tilemap
++
++$(U)tilemap.exe: $(O)tilemap.o
++	@$(link) $(LFLAGSU) -o$@ $(O)tilemap.o
++
++$(O)tilemap.o: $(WSHR)/tilemap.c $(HACK_H)
++	$(cc) $(CFLAGSU) -o$@ $(WSHR)/tilemap.c
++
++$(O)tiletx32.o: $(WSHR)/tilemap.c $(HACK_H)
++	$(cc) $(CFLAGS) -DTILETEXT -DTILE_X=32 -DTILE_Y=32 -o$@ $(WSHR)/tilemap.c
++
++$(O)tiletxt.o: $(WSHR)/tilemap.c $(HACK_H)
++	$(cc) $(CFLAGS) -DTILETEXT -o$@ $(WSHR)/tilemap.c
++
++$(O)gifread.o: $(WSHR)/gifread.c  $(CONFIG_H) $(TILE_H)
++	$(cc) $(CFLAGS) -I$(WSHR) -o$@ $(WSHR)/gifread.c
++
++$(O)gifrd32.o: $(WSHR)/gifread.c  $(CONFIG_H) $(TILE_H)
++	$(cc) $(CFLAGS) -I$(WSHR) -DTILE_X=32 -DTILE_Y=32 -o$@ $(WSHR)/gifread.c
++
++$(O)ppmwrite.o: $(WSHR)/ppmwrite.c $(CONFIG_H) $(TILE_H)
++	$(cc) $(CFLAGS) -I$(WSHR) -o$@ $(WSHR)/ppmwrite.c
++
++$(O)tiletext.o: $(WSHR)/tiletext.c  $(CONFIG_H) $(TILE_H)
++	$(cc) $(CFLAGS) -I$(WSHR) -o$@ $(WSHR)/tiletext.c
++
++$(O)tilete32.o: $(WSHR)/tiletext.c  $(CONFIG_H) $(TILE_H)
++	$(cc) $(CFLAGS) -I$(WSHR) -DTILE_X=32 -DTILE_Y=32 -o$@ $(WSHR)/tiletext.c
++
++#==========================================
++# Optional Tile Utilities
++#==========================================
++
++$(U)gif2txt.exe: $(GIFREADERS) $(TEXT_IO)
++	@echo Linking $@...
++	@$(link) $(LFLAGSU) -o$@ $(GIFREADERS) $(TEXT_IO)
++
++$(U)gif2tx32.exe: $(GIFREADERS32) $(TEXT_IO32)
++	@echo Linking $@...
++	@$(link) $(LFLAGSU) -o$@ $(GIFREADERS32) $(TEXT_IO32)
++
++
++$(U)txt2ppm.exe: $(PPMWRITERS) $(TEXT_IO)
++	@echo Linking $@...
++	@$(link) $(LFLAGSU) -o$@ $(PPMWRITERS) $(TEXT_IO)
++
++
++ifeq  "$(GRAPHICAL)" "Y"
++$(TILEBMP16): $(TILEUTIL16) $(TILEFILES)
++	@echo Creating 16x16 binary tile files (this may take some time)
++	$(subst /,\,@$(U)tile2bmp $(TILEBMP16))
++#$(TILEBMP32): $(TILEUTIL32) $(TILEFILES32)
++#	@echo Creating 32x32 binary tile files (this may take some time)
++#	$(subst /,\,@$(U)til2bm32 $(TILEBMP32))
++else
++$(TILEBMP16):
++$(TILEBMP32):
++endif
++
++$(U)tile2bmp.exe: $(O)tile2bmp.o $(TEXT_IO)
++	@echo Linking $@...
++	@$(link) $(LFLAGSU) -o$@ $(O)tile2bmp.o $(TEXT_IO)
++
++$(U)til2bm32.exe: $(O)til2bm32.o $(TEXT_IO32)
++	@echo Linking $@...
++	@$(link) $(LFLAGSU) -o$@ $(O)til2bm32.o $(TEXT_IO32)
++
++$(O)tile2bmp.o: $(WSHR)/tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)/win32api.h
++	$(cc) $(CFLAGS) -I$(WSHR) -o$@ $(WSHR)/tile2bmp.c
++
++$(O)til2bm32.o: $(WSHR)/til2bm32.c $(HACK_H) $(TILE_H) $(INCL)/win32api.h
++	$(cc) $(CFLAGS) -I$(WSHR) -DTILE_X=32 -DTILE_Y=32 -o$@ $(WSHR)/til2bm32.c
++
++#==========================================
++# Housekeeping
++#==========================================
++
++spotless: clean
++	$(subst /,\,if exist graphicschk       del graphicschk)
++	$(subst /,\,if exist $(INCL)/date.h    del $(INCL)/date.h)
++	$(subst /,\,if exist $(INCL)/onames.h  del $(INCL)/onames.h)
++	$(subst /,\,if exist $(INCL)/pm.h      del $(INCL)/pm.h)
++	$(subst /,\,if exist $(INCL)/vis_tab.h del $(INCL)/vis_tab.h)
++	$(subst /,\,if exist $(SRC)/vis_tab.c  del $(SRC)/vis_tab.c)
++	$(subst /,\,if exist $(SRC)/tile.c     del $(SRC)/tile.c)
++	$(subst /,\,if exist $(U)*.lnk         del $(U)*.lnk)
++	$(subst /,\,if exist $(U)*.map         del $(U)*.map)
++	$(subst /,\,if exist $(DAT)/data       del $(DAT)/data)
++	$(subst /,\,if exist $(DAT)/rumors     del $(DAT)/rumors)
++	$(subst /,\,if exist $(DAT)/???-fil?.lev      del $(DAT)/???-fil?.lev)
++	$(subst /,\,if exist $(DAT)/???-goal.lev      del $(DAT)/???-goal.lev)
++	$(subst /,\,if exist $(DAT)/???-loca.lev      del $(DAT)/???-loca.lev)
++	$(subst /,\,if exist $(DAT)/???-strt.lev      del $(DAT)/???-strt.lev)
++	$(subst /,\,if exist $(DAT)/air.lev      del $(DAT)/air.lev)
++	$(subst /,\,if exist $(DAT)/asmodeus.lev      del $(DAT)/asmodeus.lev)
++	$(subst /,\,if exist $(DAT)/astral.lev   del $(DAT)/astral.lev)
++	$(subst /,\,if exist $(DAT)/baalz.lev    del $(DAT)/baalz.lev)
++	$(subst /,\,if exist $(DAT)/bigrm-*.lev  del $(DAT)/bigrm-*.lev)
++	$(subst /,\,if exist $(DAT)/castle.lev   del $(DAT)/castle.lev)
++	$(subst /,\,if exist $(DAT)/data    del $(DAT)/data)
++	$(subst /,\,if exist $(DAT)/dungeon      del $(DAT)/dungeon)
++	$(subst /,\,if exist $(DAT)/dungeon.pdf  del $(DAT)/dungeon.pdf)
++	$(subst /,\,if exist $(DAT)/earth.lev    del $(DAT)/earth.lev)
++	$(subst /,\,if exist $(DAT)/fakewiz?.lev      del $(DAT)/fakewiz?.lev)
++	$(subst /,\,if exist $(DAT)/fire.lev     del $(DAT)/fire.lev)
++	$(subst /,\,if exist $(DAT)/juiblex.lev  del $(DAT)/juiblex.lev)
++	$(subst /,\,if exist $(DAT)/knox.lev     del $(DAT)/knox.lev)
++	$(subst /,\,if exist $(DAT)/medusa-?.lev      del $(DAT)/medusa-?.lev)
++	$(subst /,\,if exist $(DAT)/mine*.lev    del $(DAT)/mine*.lev)
++	$(subst /,\,if exist $(DAT)/options      del $(DAT)/options)
++	$(subst /,\,if exist $(DAT)/ttyoptions   del $(DAT)/ttyoptions)
++	$(subst /,\,if exist $(DAT)/guioptions   del $(DAT)/guioptions)
++	$(subst /,\,if exist $(DAT)/oracle.lev   del $(DAT)/oracle.lev)
++	$(subst /,\,if exist $(DAT)/oracles      del $(DAT)/oracles)
++	$(subst /,\,if exist $(DAT)/orcus.lev    del $(DAT)/orcus.lev)
++	$(subst /,\,if exist $(DAT)/rumors  del $(DAT)/rumors)
++	$(subst /,\,if exist $(DAT)/quest.dat    del $(DAT)/quest.dat)
++	$(subst /,\,if exist $(DAT)/sanctum.lev  del $(DAT)/sanctum.lev)
++	$(subst /,\,if exist $(DAT)/soko?-?.lev  del $(DAT)/soko?-?.lev)
++	$(subst /,\,if exist $(DAT)/tower?.lev   del $(DAT)/tower?.lev)
++	$(subst /,\,if exist $(DAT)/valley.lev   del $(DAT)/valley.lev)
++	$(subst /,\,if exist $(DAT)/water.lev    del $(DAT)/water.lev)
++	$(subst /,\,if exist $(DAT)/wizard?.lev  del $(DAT)/wizard?.lev)
++	$(subst /,\,if exist $(O)sp_lev.tag     del $(O)sp_lev.tag)
++	$(subst /,\,if exist $(SRC)/monstr.c    del $(SRC)/monstr.c)
++	$(subst /,\,if exist $(SRC)/vis_tab.c   del $(SRC)/vis_tab.c)
++	$(subst /,\,if exist $(U)recover.exe    del $(U)recover.exe)
++	$(subst /,\,if exist $(DAT)/dlb.lst      del $(DAT)/dlb.lst)
++	$(subst /,\,if exist nhdat.         del nhdat.)
++	$(subst /,\,if exist $(O)install.tag    del $(O)install.tag)
++	$(subst /,\,if exist $(O)obj.tag    del $(O)obj.tag)
++	$(subst /,\,if exist $(O)gamedir.tag    del $(O)gamedir.tag)
++ifneq "$(OBJ)" ""
++	$(subst /,\,rmdir $(OBJ)) /s /Q
++endif
++
++clean:
++	$(subst /,\,if exist $(O)*.o del $(O)*.o)
++	$(subst /,\,if exist $(O)utility.tag   del $(O)utility.tag)
++	$(subst /,\,if exist $(U)makedefs.exe  del $(U)makedefs.exe)
++	$(subst /,\,if exist $(U)lev_comp.exe  del $(U)lev_comp.exe)
++	$(subst /,\,if exist $(U)dgn_comp.exe  del $(U)dgn_comp.exe)
++	$(subst /,\,if exist $(SRC)/*.lnk      del $(SRC)/*.lnk)
++	$(subst /,\,if exist $(SRC)/*.map      del $(SRC)/*.map)
++	$(subst /,\,if exist $(TILEBMP16)      del $(TILEBMP16))
++	$(subst /,\,if exist $(TILEBMP32)      del $(TILEBMP32))
++
++#===================================================================
++# OTHER DEPENDENCIES
++#===================================================================
++
++#
++# dat dependencies
++#
++
++$(DAT)/data: $(O)utility.tag    $(DATABASE)
++	$(subst /,\,$(U)makedefs -d)
++
++$(DAT)/rumors: $(O)utility.tag    $(DAT)/rumors.tru   $(DAT)/rumors.fal
++	$(subst /,\,$(U)makedefs -r)
++
++$(DAT)/quest.dat: $(O)utility.tag  $(DAT)/quest.txt
++	$(subst /,\,$(U)makedefs -q)
++
++$(DAT)/oracles: $(O)utility.tag    $(DAT)/oracles.txt
++	$(subst /,\,$(U)makedefs -h)
++
++$(DAT)/dungeon: $(O)utility.tag  $(DAT)/dungeon.def
++	$(subst /,\,$(U)makedefs -e)
++	$(subst /,\,$(U)dgn_comp $(DAT)/dungeon.pdf)
++
++#
++# NT dependencies
++#
++
++$(O)nttty.o:   $(HACK_H) $(TILE_H) $(INCL)/win32api.h $(NTSYS)/nttty.c
++	$(cc) $(CFLAGS) -I$(WSHR) -o$@  $(NTSYS)/nttty.c
++$(O)winnt.o: $(HACK_H) $(INCL)/win32api.h $(NTSYS)/winnt.c
++	$(cc) $(CFLAGS) -o$@  $(NTSYS)/winnt.c
++$(O)ntsound.o: $(HACK_H) $(NTSYS)/ntsound.c
++	$(cc) $(CFLAGS)  -o$@ $(NTSYS)/ntsound.c
++$(O)mapimail.o: $(HACK_H) $(INCL)/nhlan.h $(NTSYS)/mapimail.c
++	$(cc) $(CFLAGS) -DMAPI_VERBOSE  -o$@ $(NTSYS)/mapimail.c
++
++#
++# util dependencies
++#
++
++$(O)panic.o:  $(U)panic.c $(CONFIG_H)
++	$(cc) $(CFLAGS) -o$@ $(U)panic.c
++
++#
++# The rest are stolen from sys/unix/Makefile.src,
++# with the following changes:
++#   * ../include changed to $(INCL)
++#   * -c (which is included in CFLAGS) substituted
++#	with -o$@
++#   * targets prefixed with $(O)
++#   * $(CC) changed to $(cc)
++# but otherwise untouched. 
++# That means that there is some irrelevant stuff
++# in here, but maintenance should be easier.
++#
++$(O)tos.o: ../sys/atari/tos.c $(HACK_H) $(INCL)/tcap.h
++	$(cc) $(CFLAGS) -o$@ ../sys/atari/tos.c
++$(O)pcmain.o: ../sys/share/pcmain.c $(HACK_H) $(INCL)/dlb.h \
++		$(INCL)/win32api.h
++	$(cc) $(CFLAGS) -o$@ ../sys/share/pcmain.c
++$(O)pcsys.o: ../sys/share/pcsys.c $(HACK_H)
++	$(cc) $(CFLAGS) -o$@ ../sys/share/pcsys.c
++$(O)pctty.o: ../sys/share/pctty.c $(HACK_H)
++	$(cc) $(CFLAGS) -o$@ ../sys/share/pctty.c
++$(O)pcunix.o: ../sys/share/pcunix.c $(HACK_H)
++	$(cc) $(CFLAGS) -o$@ ../sys/share/pcunix.c
++$(O)random.o: ../sys/share/random.c $(HACK_H)
++	$(cc) $(CFLAGS) -o$@ ../sys/share/random.c
++$(O)ioctl.o: ../sys/share/ioctl.c $(HACK_H) $(INCL)/tcap.h
++	$(cc) $(CFLAGS) -o$@ ../sys/share/ioctl.c
++$(O)unixtty.o: ../sys/share/unixtty.c $(HACK_H)
++	$(cc) $(CFLAGS) -o$@ ../sys/share/unixtty.c
++$(O)unixmain.o: ../sys/unix/unixmain.c $(HACK_H) $(INCL)/dlb.h
++	$(cc) $(CFLAGS) -o$@ ../sys/unix/unixmain.c
++$(O)unixunix.o: ../sys/unix/unixunix.c $(HACK_H)
++	$(cc) $(CFLAGS) -o$@ ../sys/unix/unixunix.c
++$(O)unixres.o: ../sys/unix/unixres.c $(CONFIG_H)
++	$(cc) $(CFLAGS) -o$@ ../sys/unix/unixres.c
++$(O)bemain.o: ../sys/be/bemain.c $(HACK_H) $(INCL)/dlb.h
++	$(cc) $(CFLAGS) -o$@ ../sys/be/bemain.c
++$(O)getline.o: ../win/tty/getline.c $(HACK_H) $(INCL)/func_tab.h
++	$(cc) $(CFLAGS) -o$@ ../win/tty/getline.c
++$(O)termcap.o: ../win/tty/termcap.c $(HACK_H) $(INCL)/tcap.h
++	$(cc) $(CFLAGS) -o$@ ../win/tty/termcap.c
++$(O)topl.o: ../win/tty/topl.c $(HACK_H) $(INCL)/tcap.h
++	$(cc) $(CFLAGS) -o$@ ../win/tty/topl.c
++$(O)wintty.o: ../win/tty/wintty.c $(HACK_H) $(INCL)/dlb.h \
++		$(INCL)/patchlevel.h $(INCL)/tcap.h
++	$(cc) $(CFLAGS) -o$@ ../win/tty/wintty.c
++$(O)Window.o: ../win/X11/Window.c $(INCL)/xwindowp.h $(INCL)/xwindow.h \
++		$(CONFIG_H)
++	$(cc) $(CFLAGS) -o$@ ../win/X11/Window.c
++$(O)dialogs.o: ../win/X11/dialogs.c $(CONFIG_H)
++	$(cc) $(CFLAGS) -o$@ ../win/X11/dialogs.c
++$(O)winX.o: ../win/X11/winX.c $(HACK_H) $(INCL)/winX.h $(INCL)/dlb.h \
++		$(INCL)/patchlevel.h ../win/X11/nh72icon \
++		../win/X11/nh56icon ../win/X11/nh32icon
++	$(cc) $(CFLAGS) -o$@ ../win/X11/winX.c
++$(O)winmap.o: ../win/X11/winmap.c $(INCL)/xwindow.h $(HACK_H) $(INCL)/dlb.h \
++		$(INCL)/winX.h $(INCL)/tile2x11.h
++	$(cc) $(CFLAGS) -o$@ ../win/X11/winmap.c
++$(O)winmenu.o: ../win/X11/winmenu.c $(HACK_H) $(INCL)/winX.h
++	$(cc) $(CFLAGS) -o$@ ../win/X11/winmenu.c
++$(O)winmesg.o: ../win/X11/winmesg.c $(INCL)/xwindow.h $(HACK_H) $(INCL)/winX.h
++	$(cc) $(CFLAGS) -o$@ ../win/X11/winmesg.c
++$(O)winmisc.o: ../win/X11/winmisc.c $(HACK_H) $(INCL)/func_tab.h \
++		$(INCL)/winX.h
++	$(cc) $(CFLAGS) -o$@ ../win/X11/winmisc.c
++$(O)winstat.o: ../win/X11/winstat.c $(HACK_H) $(INCL)/winX.h
++	$(cc) $(CFLAGS) -o$@ ../win/X11/winstat.c
++$(O)wintext.o: ../win/X11/wintext.c $(HACK_H) $(INCL)/winX.h $(INCL)/xwindow.h
++	$(cc) $(CFLAGS) -o$@ ../win/X11/wintext.c
++$(O)winval.o: ../win/X11/winval.c $(HACK_H) $(INCL)/winX.h
++	$(cc) $(CFLAGS) -o$@ ../win/X11/winval.c
++$(O)tile.o: tile.c $(HACK_H)
++$(O)gnaskstr.o: ../win/gnome/gnaskstr.c ../win/gnome/gnaskstr.h \
++		../win/gnome/gnmain.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnaskstr.c
++$(O)gnbind.o: ../win/gnome/gnbind.c ../win/gnome/gnbind.h ../win/gnome/gnmain.h \
++		../win/gnome/gnaskstr.h ../win/gnome/gnyesno.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnbind.c
++$(O)gnglyph.o: ../win/gnome/gnglyph.c ../win/gnome/gnglyph.h $(INCL)/tile2x11.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnglyph.c
++$(O)gnmain.o: ../win/gnome/gnmain.c ../win/gnome/gnmain.h ../win/gnome/gnsignal.h \
++		../win/gnome/gnbind.h ../win/gnome/gnopts.h $(HACK_H) \
++		$(INCL)/date.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnmain.c
++$(O)gnmap.o: ../win/gnome/gnmap.c ../win/gnome/gnmap.h ../win/gnome/gnglyph.h \
++		../win/gnome/gnsignal.h $(HACK_H)
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnmap.c
++$(O)gnmenu.o: ../win/gnome/gnmenu.c ../win/gnome/gnmenu.h ../win/gnome/gnmain.h \
++		../win/gnome/gnbind.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnmenu.c
++$(O)gnmesg.o: ../win/gnome/gnmesg.c ../win/gnome/gnmesg.h ../win/gnome/gnsignal.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnmesg.c
++$(O)gnopts.o: ../win/gnome/gnopts.c ../win/gnome/gnopts.h ../win/gnome/gnglyph.h \
++		../win/gnome/gnmain.h ../win/gnome/gnmap.h $(HACK_H)
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnopts.c
++$(O)gnplayer.o: ../win/gnome/gnplayer.c ../win/gnome/gnplayer.h \
++		../win/gnome/gnmain.h $(HACK_H)
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnplayer.c
++$(O)gnsignal.o: ../win/gnome/gnsignal.c ../win/gnome/gnsignal.h \
++		../win/gnome/gnmain.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnsignal.c
++$(O)gnstatus.o: ../win/gnome/gnstatus.c ../win/gnome/gnstatus.h \
++		../win/gnome/gnsignal.h ../win/gnome/gn_xpms.h \
++		../win/gnome/gnomeprv.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnstatus.c
++$(O)gntext.o: ../win/gnome/gntext.c ../win/gnome/gntext.h ../win/gnome/gnmain.h \
++		../win/gnome/gn_rip.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gntext.c
++$(O)gnworn.o: ../win/gnome/gnworn.c ../win/gnome/gnworn.h ../win/gnome/gnglyph.h \
++		../win/gnome/gnsignal.h ../win/gnome/gnomeprv.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnworn.c
++$(O)gnyesno.o: ../win/gnome/gnyesno.c ../win/gnome/gnbind.h ../win/gnome/gnyesno.h
++	$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnyesno.c
++$(O)wingem.o: ../win/gem/wingem.c $(HACK_H) $(INCL)/func_tab.h $(INCL)/dlb.h \
++		$(INCL)/patchlevel.h $(INCL)/wingem.h
++	$(cc) $(CFLAGS) -o$@ ../win/gem/wingem.c
++$(O)wingem1.o: ../win/gem/wingem1.c $(INCL)/gem_rsc.h $(INCL)/load_img.h \
++		$(INCL)/gr_rect.h $(INCL)/wintype.h $(INCL)/wingem.h
++	$(cc) $(CFLAGS) -o$@ ../win/gem/wingem1.c
++$(O)load_img.o: ../win/gem/load_img.c $(INCL)/load_img.h
++	$(cc) $(CFLAGS) -o$@ ../win/gem/load_img.c
++$(O)gr_rect.o: ../win/gem/gr_rect.c $(INCL)/gr_rect.h
++	$(cc) $(CFLAGS) -o$@ ../win/gem/gr_rect.c
++$(O)tile.o: tile.c $(HACK_H)
++$(O)qt_win.o: ../win/Qt/qt_win.cpp $(HACK_H) $(INCL)/func_tab.h \
++		$(INCL)/dlb.h $(INCL)/patchlevel.h $(INCL)/tile2x11.h \
++		$(INCL)/qt_win.h $(INCL)/qt_clust.h $(INCL)/qt_kde0.h \
++		$(INCL)/qt_xpms.h qt_win.moc qt_kde0.moc qttableview.moc
++	$(CXX) $(CXXFLAGS) -o$@ ../win/Qt/qt_win.cpp
++$(O)qt_clust.o: ../win/Qt/qt_clust.cpp $(INCL)/qt_clust.h
++	$(CXX) $(CXXFLAGS) -o$@ ../win/Qt/qt_clust.cpp
++$(O)qttableview.o: ../win/Qt/qttableview.cpp $(INCL)/qttableview.h
++	$(CXX) $(CXXFLAGS) -o$@ ../win/Qt/qttableview.cpp
++$(O)monstr.o: monstr.c $(CONFIG_H)
++$(O)vis_tab.o: vis_tab.c $(CONFIG_H) $(INCL)/vis_tab.h
++$(O)allmain.o: allmain.c $(HACK_H)
++$(O)alloc.o: alloc.c $(CONFIG_H)
++$(O)apply.o: apply.c $(HACK_H) $(INCL)/edog.h
++$(O)artifact.o: artifact.c $(HACK_H) $(INCL)/artifact.h $(INCL)/artilist.h
++$(O)attrib.o: attrib.c $(HACK_H)
++$(O)ball.o: ball.c $(HACK_H)
++$(O)bones.o: bones.c $(HACK_H) $(INCL)/lev.h
++$(O)botl.o: botl.c $(HACK_H)
++$(O)cmd.o: cmd.c $(HACK_H) $(INCL)/func_tab.h
++$(O)dbridge.o: dbridge.c $(HACK_H)
++$(O)decl.o: decl.c $(HACK_H)
++$(O)detect.o: detect.c $(HACK_H) $(INCL)/artifact.h
++$(O)dig.o: dig.c $(HACK_H) $(INCL)/edog.h
++$(O)display.o: display.c $(HACK_H)
++$(O)dlb.o: dlb.c $(CONFIG_H) $(INCL)/dlb.h
++$(O)do.o: do.c $(HACK_H) $(INCL)/lev.h
++$(O)do_name.o: do_name.c $(HACK_H)
++$(O)do_wear.o: do_wear.c $(HACK_H)
++$(O)dog.o: dog.c $(HACK_H) $(INCL)/edog.h
++$(O)dogmove.o: dogmove.c $(HACK_H) $(INCL)/mfndpos.h $(INCL)/edog.h
++$(O)dokick.o: dokick.c $(HACK_H) $(INCL)/eshk.h
++$(O)dothrow.o: dothrow.c $(HACK_H) $(INCL)/edog.h
++$(O)drawing.o: drawing.c $(HACK_H) $(INCL)/tcap.h
++$(O)dungeon.o: dungeon.c $(HACK_H) $(INCL)/dgn_file.h $(INCL)/dlb.h
++$(O)eat.o: eat.c $(HACK_H)
++$(O)end.o: end.c $(HACK_H) $(INCL)/eshk.h $(INCL)/dlb.h
++$(O)engrave.o: engrave.c $(HACK_H) $(INCL)/lev.h
++$(O)exper.o: exper.c $(HACK_H)
++$(O)explode.o: explode.c $(HACK_H)
++$(O)extralev.o: extralev.c $(HACK_H)
++$(O)files.o: files.c $(HACK_H) $(INCL)/dlb.h
++$(O)fountain.o: fountain.c $(HACK_H)
++$(O)hack.o: hack.c $(HACK_H)
++$(O)hacklib.o: hacklib.c $(HACK_H)
++$(O)invent.o: invent.c $(HACK_H)
++$(O)light.o: light.c $(HACK_H) $(INCL)/lev.h
++$(O)lock.o: lock.c $(HACK_H)
++$(O)mail.o: mail.c $(HACK_H) $(INCL)/mail.h
++$(O)makemon.o: makemon.c $(HACK_H) $(INCL)/epri.h $(INCL)/emin.h \
++		$(INCL)/edog.h
++$(O)mapglyph.o: mapglyph.c $(HACK_H)
++$(O)mcastu.o: mcastu.c $(HACK_H)
++$(O)mhitm.o: mhitm.c $(HACK_H) $(INCL)/artifact.h $(INCL)/edog.h
++$(O)mhitu.o: mhitu.c $(HACK_H) $(INCL)/artifact.h $(INCL)/edog.h
++$(O)minion.o: minion.c $(HACK_H) $(INCL)/emin.h $(INCL)/epri.h
++$(O)mklev.o: mklev.c $(HACK_H)
++$(O)mkmap.o: mkmap.c $(HACK_H) $(INCL)/sp_lev.h
++$(O)mkmaze.o: mkmaze.c $(HACK_H) $(INCL)/sp_lev.h $(INCL)/lev.h
++$(O)mkobj.o: mkobj.c $(HACK_H)
++$(O)mkroom.o: mkroom.c $(HACK_H)
++$(O)mon.o: mon.c $(HACK_H) $(INCL)/mfndpos.h $(INCL)/edog.h
++$(O)mondata.o: mondata.c $(HACK_H) $(INCL)/eshk.h $(INCL)/epri.h
++$(O)monmove.o: monmove.c $(HACK_H) $(INCL)/mfndpos.h $(INCL)/artifact.h \
++		$(INCL)/epri.h
++$(O)monst.o: monst.c $(CONFIG_H) $(INCL)/permonst.h $(INCL)/align.h \
++		$(INCL)/monattk.h $(INCL)/monflag.h $(INCL)/monsym.h \
++		$(INCL)/dungeon.h $(INCL)/eshk.h $(INCL)/vault.h \
++		$(INCL)/epri.h $(INCL)/color.h
++$(O)mplayer.o: mplayer.c $(HACK_H)
++$(O)mthrowu.o: mthrowu.c $(HACK_H)
++$(O)muse.o: muse.c $(HACK_H) $(INCL)/edog.h
++$(O)music.o: music.c $(HACK_H) #interp.c
++$(O)o_init.o: o_init.c $(HACK_H) $(INCL)/lev.h
++$(O)objects.o: objects.c $(CONFIG_H) $(INCL)/obj.h $(INCL)/objclass.h \
++		$(INCL)/prop.h $(INCL)/skills.h $(INCL)/color.h
++$(O)objnam.o: objnam.c $(HACK_H)
++$(O)options.o: options.c $(CONFIG_H) $(INCL)/objclass.h $(INCL)/flag.h \
++		$(HACK_H) $(INCL)/tcap.h
++$(O)pager.o: pager.c $(HACK_H) $(INCL)/dlb.h
++$(O)pickup.o: pickup.c $(HACK_H)
++$(O)pline.o: pline.c $(HACK_H) $(INCL)/epri.h $(INCL)/edog.h
++$(O)polyself.o: polyself.c $(HACK_H)
++$(O)potion.o: potion.c $(HACK_H)
++$(O)pray.o: pray.c $(HACK_H) $(INCL)/epri.h
++$(O)priest.o: priest.c $(HACK_H) $(INCL)/mfndpos.h $(INCL)/eshk.h \
++		$(INCL)/epri.h $(INCL)/emin.h
++$(O)quest.o: quest.c $(HACK_H) $(INCL)/qtext.h
++$(O)questpgr.o: questpgr.c $(HACK_H) $(INCL)/dlb.h $(INCL)/qtext.h
++$(O)read.o: read.c $(HACK_H)
++$(O)rect.o: rect.c $(HACK_H)
++$(O)region.o: region.c $(HACK_H) $(INCL)/lev.h
++$(O)restore.o: restore.c $(HACK_H) $(INCL)/lev.h $(INCL)/tcap.h
++$(O)rip.o: rip.c $(HACK_H)
++$(O)rnd.o: rnd.c $(HACK_H)
++$(O)role.o: role.c $(HACK_H)
++$(O)rumors.o: rumors.c $(HACK_H) $(INCL)/lev.h $(INCL)/dlb.h
++$(O)save.o: save.c $(HACK_H) $(INCL)/lev.h
++$(O)shk.o: shk.c $(HACK_H) $(INCL)/eshk.h
++$(O)shknam.o: shknam.c $(HACK_H) $(INCL)/eshk.h
++$(O)sit.o: sit.c $(HACK_H) $(INCL)/artifact.h
++$(O)sounds.o: sounds.c $(HACK_H) $(INCL)/edog.h
++$(O)sp_lev.o: sp_lev.c $(HACK_H) $(INCL)/dlb.h $(INCL)/sp_lev.h
++$(O)spell.o: spell.c $(HACK_H)
++$(O)steal.o: steal.c $(HACK_H)
++$(O)steed.o: steed.c $(HACK_H)
++$(O)teleport.o: teleport.c $(HACK_H)
++$(O)timeout.o: timeout.c $(HACK_H) $(INCL)/lev.h
++$(O)topten.o: topten.c $(HACK_H) $(INCL)/dlb.h $(INCL)/patchlevel.h
++$(O)track.o: track.c $(HACK_H)
++$(O)trap.o: trap.c $(HACK_H)
++$(O)u_init.o: u_init.c $(HACK_H)
++$(O)uhitm.o: uhitm.c $(HACK_H)
++$(O)vault.o: vault.c $(HACK_H) $(INCL)/vault.h
++$(O)version.o: version.c $(HACK_H) $(INCL)/date.h $(INCL)/patchlevel.h
++$(O)vision.o: vision.c $(HACK_H) $(INCL)/vis_tab.h
++$(O)weapon.o: weapon.c $(HACK_H)
++$(O)were.o: were.c $(HACK_H)
++$(O)wield.o: wield.c $(HACK_H)
++$(O)windows.o: windows.c $(HACK_H) $(INCL)/wingem.h $(INCL)/winGnome.h
++$(O)wizard.o: wizard.c $(HACK_H) $(INCL)/qtext.h $(INCL)/epri.h
++$(O)worm.o: worm.c $(HACK_H) $(INCL)/lev.h
++$(O)worn.o: worn.c $(HACK_H)
++$(O)write.o: write.c $(HACK_H)
++$(O)zap.o: zap.c $(HACK_H)
++
++# end of file
+diff -burN nethack-3.4.3/util/makedefs.c nethack/util/makedefs.c
+--- nethack-3.4.3/util/makedefs.c	2003-12-07 18:39:13.000000000 -0500
++++ nethack/util/makedefs.c	2009-03-11 13:35:46.000000000 -0400
+@@ -782,6 +782,9 @@
+ #ifdef TTY_GRAPHICS
+ 		"traditional tty-based graphics",
+ #endif
++#ifdef CURSES_GRAPHICS
++        "curses",
++#endif
+ #ifdef X11_GRAPHICS
+ 		"X11",
+ #endif
+diff -burN nethack-3.4.3/win/curses/Bugs.txt nethack/win/curses/Bugs.txt
+--- nethack-3.4.3/win/curses/Bugs.txt	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/Bugs.txt	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,13 @@
++Here is a list of known issues with the curses interface at the time of
++this writing.  Send any others you discover to me (Karl Garrison) at
++kgarrison@obox.com, along with how to reproduce the problem, if
++possible.  Missing features are listed in the file Todo.txt.
++
++ * Resizing a window to 80 columns or less causes a crash (PDCurses for
++ SDL and X11 only).  Windows starting at this size and below do not
++ cause a crash, however.
++ 
++ * Cursor position is wrong on map for smaller terminal windows in all
++ versions of PDCurses (smaller than 80 width or 24 height).  This is
++ due to an incomplete workaround for an issue with the wmove() function
++ in PDCurses.
+diff -burN nethack-3.4.3/win/curses/cursdial.c nethack/win/curses/cursdial.c
+--- nethack-3.4.3/win/curses/cursdial.c	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursdial.c	2009-03-11 15:08:53.000000000 -0400
+@@ -0,0 +1,1182 @@
++#include "curses.h"
++#include "hack.h"
++#include "wincurs.h"
++#include "cursdial.h"
++#include "func_tab.h"
++
++
++/* Dialog windows for curses interface */
++
++static nhmenu *nhmenus = NULL;  /* NetHack menu array */
++
++
++/* Get a line of text from the player, such as asking for a character name or a wish */
++
++void curses_line_input_dialog(const char *prompt, char *answer, int buffer)
++{
++    int map_height, map_width, maxwidth, remaining_buf, winx, winy, count;
++    WINDOW *askwin, *bwin;
++    char input[buffer];
++    char *tmpstr;
++    int prompt_width = strlen(prompt) + buffer + 1;
++    int prompt_height = 1;
++    int height = prompt_height;
++
++    maxwidth = term_cols - 2;
++
++    if (iflags.window_inited)
++    {
++        curses_get_window_size(MAP_WIN, &map_height, &map_width);
++        if ((prompt_width + 2) > map_width)
++            maxwidth = map_width - 2;
++    }
++    
++    if (prompt_width > maxwidth)
++    {
++        prompt_height = curses_num_lines(prompt, maxwidth);
++        height = prompt_height;
++        prompt_width = maxwidth;
++        tmpstr = curses_break_str(prompt, maxwidth, prompt_height);
++        remaining_buf = buffer - (strlen(tmpstr) - 1);
++        if (remaining_buf > 0 )
++        {
++            height += (remaining_buf / prompt_width);
++            if ((remaining_buf % prompt_width) > 0)
++            {
++                height++;
++            }
++        }
++    }
++    
++    if (iflags.window_inited)
++    {
++        bwin = curses_create_window(prompt_width, height, UP);
++        wrefresh(bwin);
++        getbegyx(bwin, winy, winx);
++        askwin = newwin(height, prompt_width, winy + 1, winx + 1);
++    }
++    else
++    {
++        bwin = curses_create_window(prompt_width, height, CENTER);
++        wrefresh(bwin);
++        getbegyx(bwin, winy, winx);
++        askwin = newwin(height, prompt_width, winy + 1, winx + 1);
++    }
++    for (count = 0; count < prompt_height; count++)
++    {
++        tmpstr = curses_break_str(prompt, maxwidth, count + 1);
++        if (count == (prompt_height - 1))    /* Last line */
++        {
++            mvwprintw(askwin, count, 0, "%s ", tmpstr);
++        }
++        else
++        {
++            mvwaddstr(askwin, count, 0, tmpstr);
++        }
++        free(tmpstr);
++    }
++    
++    echo();
++    curs_set(1);
++    wgetnstr(askwin, input, buffer-1);
++    curs_set(0);
++    strcpy(answer, input);
++    werase(bwin);
++    delwin(bwin);
++    curses_destroy_win(askwin);
++    noecho();
++}
++
++
++/* Get a single character response from the player, such as a y/n prompt */
++
++int curses_character_input_dialog(const char *prompt, const char *choices, CHAR_P def)
++{
++    WINDOW *askwin;
++    int answer, count, maxwidth, map_height, map_width;
++    char *linestr;
++    char askstr[BUFSZ + QBUFSZ];
++    char choicestr[QBUFSZ];
++    int prompt_width = strlen(prompt);
++    int prompt_height = 1;
++    boolean any_choice = FALSE;
++
++    curses_get_window_size(MAP_WIN, &map_height, &map_width);
++    maxwidth = map_width - 2;
++    
++    if (choices != NULL)
++    {
++        choicestr[0] = ' ';
++        choicestr[1] = '[';
++        for (count = 0; choices[count] != '\0'; count++)
++        {
++            if (choices[count] == '\033')   /* Escape */
++            {
++                break;
++            }
++            choicestr[count + 2] = choices[count];
++        }
++        choicestr[count + 2] = ']';
++        if (((def >= 'A') && (def <= 'Z')) || ((def >= 'a') && (def <= 'z')))
++        {
++            choicestr[count + 3] = ' ';
++            choicestr[count + 4] = '(';
++            choicestr[count + 5] = def;
++            choicestr[count + 6] = ')';
++            choicestr[count + 7] = '\0';
++        }
++        else    /* No usable default choice */
++        {
++            choicestr[count + 3] = '\0';
++            def = '\0'; /* Mark as no default */
++        }
++        strcpy(askstr, prompt);
++        strcat(askstr, choicestr);
++    }
++    else
++    {
++        strcpy(askstr, prompt);
++        any_choice = TRUE;
++    }
++    
++    prompt_width = strlen(askstr);
++    
++    if ((prompt_width + 2) > maxwidth)
++    {
++        prompt_height = curses_num_lines(askstr, maxwidth);
++        prompt_width = map_width - 2;
++    }
++
++    if (iflags.wc_popup_dialog)
++    {
++        askwin = curses_create_window(prompt_width, prompt_height, UP);
++        for (count = 0; count < prompt_height; count++)
++        {
++            linestr = curses_break_str(askstr, maxwidth, count + 1);
++            mvwaddstr(askwin, count + 1, 1, linestr);
++            free(linestr);
++        }
++    
++        wrefresh(askwin);
++    }
++    else
++    {
++        linestr = curses_copy_of(askstr);
++        pline("%s", linestr);
++        free(linestr);
++        curs_set(1);
++    }
++
++    while (1)
++    {
++        answer = curses_read_char();
++        if (answer==KEY_ESC)
++        {
++            if (choices == NULL)
++            {
++                break;
++            }
++            answer = def;
++            for (count = 0; choices[count] != '\0'; count++)
++            {
++                if (choices[count] == 'q') /* q is preferred over n */
++                {
++                    answer = 'q';
++                }
++                else if ((choices[count] == 'n') && answer != 'q')
++                {
++                    answer = 'n';
++                }
++            }
++            break;
++        }
++        else if ((answer == '\n') || (answer == '\r'))
++        {
++            if ((choices != NULL) && (def != '\0'))
++            {
++                answer = def;
++            }
++            break;
++        }
++        if (any_choice)
++        {
++            break;
++        }
++        if (choices != NULL)
++        {
++            for (count = 0; count < strlen(choices); count++)
++            {
++                if (choices[count] == answer)
++                {
++                    break;
++                }
++            }
++            if (choices[count] == answer)
++            {
++                break;
++            }
++        }
++    }
++
++    if (iflags.wc_popup_dialog)
++    {
++        curses_destroy_win(askwin);
++    }
++    else
++    {
++        curses_clear_unhighlight_message_window();
++        curs_set(0);
++    }
++    
++    return answer;
++}
++
++
++/* Return an extended command from the user */
++
++int curses_ext_cmd()
++{
++    /* We should check the value of iflags.extmenu here, but there is
++    currently no non-menu alternative */
++
++    return extcmd_via_menu();
++}
++
++
++/* Initialize a menu from given NetHack winid */
++
++void curses_create_nhmenu(winid wid)
++{
++    nhmenu *new_menu = NULL;
++    nhmenu *menuptr = nhmenus;
++    nhmenu_item *menu_item_ptr = NULL;
++    nhmenu_item *tmp_menu_item = NULL;
++    
++    new_menu = get_menu(wid);
++    
++    if (new_menu != NULL)
++    {
++        /* Reuse existing menu, clearing out current entries */
++        menu_item_ptr = new_menu->entries;
++        
++        if (menu_item_ptr != NULL)
++        {
++            while (menu_item_ptr->next_item != NULL)
++            {
++                tmp_menu_item = menu_item_ptr->next_item;
++                free(menu_item_ptr);
++                menu_item_ptr = tmp_menu_item;
++            }
++            free(menu_item_ptr);    /* Last entry */
++            new_menu->entries = NULL;
++        }
++        if (new_menu->prompt != NULL)   /* Reusing existing menu */
++        {
++            free((char *)new_menu->prompt);
++        }    
++        return;
++    }
++    
++    new_menu = malloc(sizeof(nhmenu));
++    new_menu->wid = wid;
++    new_menu->prompt = NULL;
++    new_menu->entries = NULL;
++    new_menu->num_pages = 0;
++    new_menu->height = 0;
++    new_menu->width = 0;
++    new_menu->next_menu = NULL;
++    
++    if (nhmenus == NULL)    /* no menus in memory yet */
++    {
++        new_menu->prev_menu = NULL;
++        nhmenus = new_menu;
++    }
++    else
++    {
++        while (menuptr->next_menu != NULL)
++        {
++            menuptr = menuptr->next_menu;
++        }
++        new_menu->prev_menu = menuptr;
++        menuptr->next_menu = new_menu;
++    }
++}
++
++
++/* Add a menu item to the given menu window */
++
++void curses_add_nhmenu_item(winid wid, const ANY_P *identifier,
++ CHAR_P accelerator, CHAR_P group_accel, int attr, const char *str,
++ BOOLEAN_P presel)
++{
++    char *new_str;
++    nhmenu_item *new_item, *current_items, *menu_item_ptr;
++    nhmenu *current_menu = get_menu(wid);
++    
++    if (str == NULL)
++    {
++        return;
++    }
++
++    new_str = curses_copy_of(str);
++    curses_rtrim((char *) new_str);
++    new_item = malloc(sizeof(nhmenu_item));
++    new_item->wid = wid;
++    new_item->identifier = *identifier;
++    new_item->accelerator = accelerator;
++    new_item->group_accel = group_accel;
++    new_item->attr = attr;
++    new_item->str = new_str;
++    new_item->presel = presel;
++    new_item->selected = FALSE;
++    new_item->page_num = 0;
++    new_item->line_num = 0;
++    new_item->num_lines = 0;
++    new_item->next_item = NULL;
++    
++    if (current_menu == NULL)
++    {
++        panic("curses_add_nhmenu_item: attempt to add item to nonexistant menu");
++    }
++
++    current_items = current_menu->entries;
++    menu_item_ptr = current_items;
++
++    if (current_items == NULL)
++    {
++        new_item->prev_item = NULL;
++        current_menu->entries = new_item;
++    }
++    else
++    {
++        while (menu_item_ptr->next_item != NULL)
++        {
++            menu_item_ptr = menu_item_ptr->next_item;
++        }
++        new_item->prev_item = menu_item_ptr;
++        menu_item_ptr->next_item = new_item;
++    }
++}
++
++
++/* No more entries are to be added to menu, so details of the menu can be
++ finalized in memory */
++
++void curses_finalize_nhmenu(winid wid, const char *prompt)
++{
++    int count = 0;
++    nhmenu *current_menu = get_menu(wid);
++    nhmenu_item *menu_item_ptr = current_menu->entries;
++
++    if (current_menu == NULL)
++    {
++        panic("curses_finalize_nhmenu: attempt to finalize nonexistant menu");
++    }
++
++    while (menu_item_ptr != NULL)
++    {
++        menu_item_ptr = menu_item_ptr->next_item;
++        count++;
++    }
++
++    current_menu->num_entries = count;
++    current_menu->prompt = curses_copy_of(prompt);
++}
++
++
++/* Display a nethack menu, and return a selection, if applicable */
++
++int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P **_selected)
++{
++    nhmenu *current_menu = get_menu(wid);
++    nhmenu_item *menu_item_ptr;
++    int num_choices, num_chosen, count;
++    WINDOW *win;
++    int curpage = 1;
++    MENU_ITEM_P *selected = NULL;
++
++	*_selected = NULL;
++    
++    if (current_menu == NULL)
++    {
++        panic("curses_display_nhmenu: attempt to display nonexistant menu");
++    }
++    
++    menu_item_ptr = current_menu->entries;
++    
++    if (menu_item_ptr == NULL)
++    {
++        panic("curses_display_nhmenu: attempt to display empty menu");
++    }
++    
++    /* Reset items to unselected to clear out selections from previous
++    invocations of this menu */
++    while (menu_item_ptr != NULL)
++    {
++        menu_item_ptr->selected = FALSE;
++        menu_item_ptr = menu_item_ptr->next_item;
++    }
++
++    menu_win_size(current_menu);
++    menu_determine_pages(current_menu);
++    win = curses_create_window(current_menu->width, current_menu->height, RIGHT);
++    num_choices = menu_get_choices(current_menu, how);
++    num_chosen = menu_get_selections(win, current_menu, num_choices, how);
++    curses_destroy_win(win);
++    
++    if (num_chosen > 0)
++    {
++        selected = (MENU_ITEM_P*) malloc(num_chosen * sizeof(MENU_ITEM_P));
++        count = 0;
++        
++        menu_item_ptr = current_menu->entries;
++
++        while (menu_item_ptr != NULL)
++        {
++            if (menu_item_ptr->selected)
++            {
++                if (count == num_chosen)
++                {
++                    panic("curses_display_nhmenu: Selected items exceeds expected number");
++                }
++                selected[count].item = menu_item_ptr->identifier;
++                selected[count].count = -1;
++                count++; 
++            }
++            menu_item_ptr = menu_item_ptr->next_item;
++        }
++        
++        if (count != num_chosen)
++        {
++            panic("curses_display_nhmenu: Selected items less than expected number");
++        }
++    }
++
++    *_selected = selected;
++    
++    return num_chosen;
++}
++
++
++boolean curses_menu_exists(winid wid)
++{
++    if (get_menu(wid) != NULL)
++    {
++        return TRUE;
++    }
++    else
++    {
++        return FALSE;
++    }
++}
++
++/* Delete the menu associated with the given NetHack winid from memory */
++
++void curses_del_menu(winid wid)
++{
++    nhmenu_item *tmp_menu_item;
++    nhmenu_item *menu_item_ptr;
++    nhmenu *tmpmenu;
++    nhmenu *current_menu = get_menu(wid);
++    
++    if (current_menu == NULL)
++    {
++       return;
++    }
++    
++    menu_item_ptr = current_menu->entries;
++    
++    /* First free entries associated with this menu from memory */
++    if (menu_item_ptr != NULL)
++    {
++        while (menu_item_ptr->next_item != NULL)
++        {
++            tmp_menu_item = menu_item_ptr->next_item;
++            free(menu_item_ptr);
++            menu_item_ptr = tmp_menu_item;
++        }
++        free(menu_item_ptr);    /* Last entry */
++        current_menu->entries = NULL;
++    }
++    
++    /* Now unlink the menu from the list and free it as well */
++    if (current_menu->prev_menu != NULL)
++    {
++        tmpmenu = current_menu->prev_menu;
++        tmpmenu->next_menu = current_menu->next_menu;
++    }
++    else
++    {
++        nhmenus = current_menu->next_menu;   /* New head mode or NULL */
++    }
++    if (current_menu->next_menu != NULL)
++    {
++        tmpmenu = current_menu->next_menu;
++        tmpmenu->prev_menu = current_menu->prev_menu;
++    }
++    free(current_menu);
++}
++
++
++/* return a pointer to the menu associated with the given NetHack winid */
++
++static nhmenu *get_menu(winid wid)
++{
++    nhmenu *menuptr = nhmenus;
++
++    while (menuptr != NULL)
++    {
++        if (menuptr->wid == wid)
++        {
++            return menuptr;
++        }
++        menuptr = menuptr->next_menu;
++    }
++    
++    
++    return NULL;    /* Not found */
++}
++
++
++static char menu_get_accel(boolean first)
++{
++    char ret;
++    static char next_letter = 'a';
++    
++    if (first)
++    {
++        next_letter = 'a';
++    }
++    
++    ret = next_letter;
++    
++    if (((next_letter < 'z') && (next_letter >= 'a')) || ((next_letter < 'Z')
++     && (next_letter >= 'A')))
++    {
++        next_letter++;
++    }
++    else if (next_letter == 'z')
++    {
++        next_letter = 'A';
++    }
++    
++    return ret;
++}
++
++
++/* Determine if menu will require multiple pages to display */
++
++static boolean menu_is_multipage(nhmenu *menu, int width, int height)
++{
++    int num_lines;
++    int curline = 0;
++    nhmenu_item *menu_item_ptr = menu->entries;
++
++    if (strlen(menu->prompt) > 0)
++    {
++        curline += curses_num_lines(menu->prompt, width) + 1;
++    }
++    
++    if (menu->num_entries <= (height - curline))
++    {   
++        while (menu_item_ptr != NULL)
++        {
++            menu_item_ptr->line_num = curline;
++            if (menu_item_ptr->identifier.a_void == NULL)
++            {
++                num_lines = curses_num_lines(menu_item_ptr->str, width);
++            }
++            else
++            {
++                /* Add space for accelerator */
++                num_lines = curses_num_lines(menu_item_ptr->str, width - 4);
++            }
++            menu_item_ptr->num_lines = num_lines;
++            curline += num_lines;
++            menu_item_ptr = menu_item_ptr->next_item;
++            if (curline > height)
++            {
++                break;
++            }
++        }
++        if (menu_item_ptr == NULL)
++        {
++            return FALSE;
++        }
++    }
++    return TRUE;
++}
++
++
++/* Determine which entries go on which page, and total number of pages */
++
++static void menu_determine_pages(nhmenu *menu)
++{
++    int tmpline, num_lines;
++    int curline = 0;
++    int page_num = 1;
++    nhmenu_item *menu_item_ptr = menu->entries;
++    int width = menu->width;
++    int height = menu->height;
++    int page_end = height;
++    
++    
++    if (strlen(menu->prompt) > 0)
++    {
++        curline += curses_num_lines(menu->prompt, width) + 1;
++    }
++        
++    tmpline = curline;
++    
++    if (menu_is_multipage(menu, width, height))
++    {
++        page_end -= 2;  /* Room to display current page number */
++    }
++
++    /* Determine what entries belong on which page */
++    menu_item_ptr = menu->entries;
++    
++    while (menu_item_ptr != NULL)
++    {
++        menu_item_ptr->page_num = page_num;
++        menu_item_ptr->line_num = curline;
++        if (menu_item_ptr->identifier.a_void == NULL)
++        {
++            num_lines = curses_num_lines(menu_item_ptr->str, width);
++        }
++        else
++        {
++            /* Add space for accelerator */
++            num_lines = curses_num_lines(menu_item_ptr->str, width - 4);
++        }
++        menu_item_ptr->num_lines = num_lines;
++        curline += num_lines;
++        if (curline > page_end)
++        {
++            page_num++;
++            curline = tmpline;
++            /* Move ptr back so entry will be reprocessed on new page */
++            menu_item_ptr = menu_item_ptr->prev_item;
++        }
++        menu_item_ptr = menu_item_ptr->next_item;
++    }
++    
++    menu->num_pages = page_num;
++}
++
++
++/* Determine dimensions of menu window based on term size and entries */
++
++static void menu_win_size(nhmenu *menu)
++{
++    int width, height, maxwidth, maxheight, curentrywidth, lastline,
++     map_height, map_width;
++    int maxentrywidth = strlen(menu->prompt);
++    int maxheaderwidth = 0;
++    nhmenu_item *menu_item_ptr = menu->entries;
++    
++    maxwidth = 38;  /* Reasonable minimum usable width */
++    
++    if ((term_cols / 2) > maxwidth)
++    {
++        maxwidth = (term_cols / 2); /* Half the screen */
++    }
++    
++    maxheight = term_rows - 2;
++    
++    /* First, determine the width of the longest menu entry */
++    while (menu_item_ptr != NULL)
++    {
++        if (menu_item_ptr->identifier.a_void == NULL)
++        {
++            curentrywidth=strlen(menu_item_ptr->str);
++
++            if (curentrywidth > maxheaderwidth)
++            {
++                maxheaderwidth = curentrywidth;
++            }
++        }
++        else
++        {
++            /* Add space for accelerator */
++            curentrywidth=strlen(menu_item_ptr->str) + 4;
++        }
++        if (curentrywidth > maxentrywidth)
++        {
++            maxentrywidth = curentrywidth;          
++        }
++        menu_item_ptr = menu_item_ptr->next_item;
++    }
++    
++    /* If the widest entry is smaller than maxwidth, reduce maxwidth accordingly */
++    if (maxentrywidth < maxwidth)
++    {
++        maxwidth = maxentrywidth;
++    }
++    
++    /* Try not to wrap headers/normal text lines if possible.  We can
++    go wider than half the screen for this purpose if need be */
++    
++    if ((maxheaderwidth > maxwidth) && (maxheaderwidth < (term_cols - 2)))
++    {
++        maxwidth = maxheaderwidth;
++    }
++    
++    width = maxwidth;
++    
++    /* Possibly reduce height if only 1 page */    
++    if (!menu_is_multipage(menu, maxwidth, maxheight))   
++    {
++        menu_item_ptr = menu->entries;
++        
++        while (menu_item_ptr->next_item != NULL)
++        {
++            menu_item_ptr = menu_item_ptr->next_item;
++        }
++        
++        lastline = (menu_item_ptr->line_num) + menu_item_ptr->num_lines;
++    
++        if (lastline < maxheight)
++        {
++            maxheight = lastline;
++        }
++    }
++    else    /* If multipage, make sure we have enough width for page footer */
++    {
++        if (width < 20)
++        {
++            width = 20;
++        }
++    }
++
++    height = maxheight;
++    menu->width = width;
++    menu->height = height;
++}
++
++
++/* Displays menu selections in the given window */
++
++static void menu_display_page(nhmenu *menu, WINDOW *win, int page_num)
++{
++    nhmenu_item *menu_item_ptr;
++    int count, curletter, entry_cols, start_col, num_lines, footer_x;
++    boolean first_accel = TRUE;
++        
++    /* Cycle through entries until we are on the correct page */
++
++    menu_item_ptr = menu->entries;
++    
++    while (menu_item_ptr != NULL)
++    {
++        if (menu_item_ptr->page_num == page_num)
++        {
++            break;
++        }
++        menu_item_ptr = menu_item_ptr->next_item;
++    }
++    
++    if (menu_item_ptr == NULL)  /* Page not found */
++    {
++        panic("menu_display_page: attempt to display nonexistant page");
++    }
++
++    werase(win);
++
++    if (strlen(menu->prompt) > 0)
++    {
++        num_lines = curses_num_lines(menu->prompt, menu->width);
++        
++        for (count = 0; count < num_lines; count++)
++        {
++            mvwprintw(win, count + 1, 1, "%s",
++             curses_break_str(menu->prompt, menu->width, count + 1));
++        }
++    }
++
++    /* Display items for current page */
++    
++    while (menu_item_ptr != NULL)
++    {
++        if (menu_item_ptr->page_num != page_num)
++        {
++            break;
++        }
++        if (menu_item_ptr->identifier.a_void != NULL)
++        {
++            if (menu_item_ptr->accelerator != 0)
++            {
++                curletter = menu_item_ptr->accelerator;
++            }
++            else
++            {
++                if (first_accel)
++                {
++                    curletter = menu_get_accel(TRUE);
++                    first_accel = FALSE;
++                }
++                else
++                {
++                    curletter = menu_get_accel(FALSE);
++                }
++                menu_item_ptr->accelerator = curletter;
++            }
++            curses_toggle_color_attr(win, NONE, ATR_BOLD, ON);
++            mvwaddch(win, menu_item_ptr->line_num + 1, 2, curletter);
++            curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF);
++            if (menu_item_ptr->selected)
++            {
++                curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
++                mvwaddch(win, menu_item_ptr->line_num + 1, 1, '<');
++                mvwaddch(win, menu_item_ptr->line_num + 1, 3, '>');
++                curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
++            }
++            else
++            {
++                mvwprintw(win, menu_item_ptr->line_num + 1, 3, ") ");
++            }
++        }
++        curses_toggle_color_attr(win, NONE, menu_item_ptr->attr, ON);
++        entry_cols = menu->width;
++        start_col = 1;
++
++        if (menu_item_ptr->identifier.a_void != NULL)
++        {
++            entry_cols -= 4;
++            start_col += 4;
++        }        
++        
++        num_lines = curses_num_lines(menu_item_ptr->str, entry_cols);
++        
++        for (count = 0; count < num_lines; count++)
++        {
++            if (strlen(menu_item_ptr->str) > 0)
++            {
++                mvwprintw(win, menu_item_ptr->line_num + count + 1,
++                 start_col, "%s", curses_break_str(menu_item_ptr->str,
++                 entry_cols, count + 1));
++             }
++        }
++        curses_toggle_color_attr(win, NONE, menu_item_ptr->attr, OFF);
++        menu_item_ptr = menu_item_ptr->next_item;
++    }
++
++    if (menu->num_pages > 1)
++    {
++        footer_x = menu->width - strlen("<- (Page X of Y) ->");
++        if (menu->num_pages > 9)    /* Unlikely */
++        {
++            footer_x -= 2;
++        }
++        mvwprintw(win, menu->height, footer_x + 3, "(Page %d of %d)",
++         page_num, menu->num_pages);
++        if (page_num != 1)
++        {
++            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
++            mvwaddstr(win, menu->height, footer_x, "<=");
++            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
++        }
++        if (page_num != menu->num_pages)
++        {
++            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
++            mvwaddstr(win, menu->height, menu->width - 2, "=>");        
++            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
++        }
++    }
++    curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON);
++    box(win, 0, 0);
++    curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF);
++    wrefresh(win);
++}
++
++
++/* Add valid selections to choices array, and return the number of choices */
++
++static int menu_get_choices(nhmenu *menu, int how)
++{
++    char curletter;
++    int count = 0;
++    int accel_idx = 0;
++    nhmenu_item *menu_item_ptr = menu->entries;
++    
++    if (how == PICK_NONE)
++        return 0;
++
++    while (menu_item_ptr != NULL)
++    {
++        if (menu_item_ptr->identifier.a_void != NULL)
++        {
++            if (menu_item_ptr->accelerator != 0)
++            {
++                curletter = menu_item_ptr->accelerator;
++            }
++            else
++            {
++                if (accel_idx == 0)
++                {
++                    curletter = menu_get_accel(TRUE);
++                }
++                else
++                {
++                    curletter = menu_get_accel(FALSE);
++                }
++                menu_item_ptr->accelerator = curletter;
++            }
++            accel_idx++;
++        }
++        menu_item_ptr = menu_item_ptr->next_item;
++        count++;
++    }
++    return count;
++}
++
++
++
++static int menu_get_selections(WINDOW *win, nhmenu *menu, int num_choices, int how)
++{
++    int count, curletter;
++    int curpage = 1;
++    int num_selected = 0;
++    boolean dismiss = FALSE;
++    nhmenu_item *menu_item_ptr = menu->entries;
++
++    menu_display_page(menu, win, 1);
++
++    while (!dismiss)
++    {
++        curletter = getch();
++        
++        switch (curletter)
++        {
++            case KEY_ESC:
++            {
++                num_selected = -1;
++                dismiss = TRUE;
++                break;
++            }
++            case '\n':
++            case '\r':
++            {
++                dismiss = TRUE;
++                break;
++            }
++            case KEY_RIGHT:
++            case KEY_NPAGE:
++            case MENU_NEXT_PAGE:
++            case ' ':
++            {
++                if (curpage < menu->num_pages)
++                {
++                    curpage++;
++                    menu_display_page(menu, win, curpage);
++                }
++                break;
++            }
++            case KEY_LEFT:
++            case KEY_PPAGE:
++            case MENU_PREVIOUS_PAGE:
++            {
++                if (curpage > 1)
++                {
++                    curpage--;
++                    menu_display_page(menu, win, curpage);
++                }
++                break;
++            }
++            case KEY_END:
++            case MENU_LAST_PAGE:
++            {
++                if (curpage != menu->num_pages)
++                {
++                    curpage = menu->num_pages;
++                    menu_display_page(menu, win, curpage);
++                }
++                break;
++            }
++            case KEY_HOME:
++            case MENU_FIRST_PAGE:
++            {
++                if (curpage != 1)
++                {
++                    curpage = 1;
++                    menu_display_page(menu, win, curpage);
++                }
++                break;
++            }
++        }
++        if (how == PICK_ANY)
++        {
++            switch (curletter)
++                {
++                case MENU_SELECT_PAGE:
++                {
++                    (void) menu_operation(win, menu, SELECT, curpage);
++                    break;
++                }
++                case MENU_SELECT_ALL:
++                {
++                    curpage = menu_operation(win, menu, SELECT, 0);
++                    break;
++                }
++                case MENU_UNSELECT_PAGE:
++                {
++                    (void) menu_operation(win, menu, DESELECT, curpage);
++                    break;
++                }
++                case MENU_UNSELECT_ALL:
++                {
++                    curpage = menu_operation(win, menu, DESELECT, 0);
++                    break;
++                }
++                case MENU_INVERT_PAGE:
++                {
++                    (void) menu_operation(win, menu, INVERT, curpage);
++                    break;
++                }
++                case MENU_INVERT_ALL:
++                {
++                    curpage = menu_operation(win, menu, INVERT, 0);
++                    break;
++                }
++            }
++        }
++        
++        menu_item_ptr = menu->entries;
++        
++        while ((menu_item_ptr != NULL) && (how != PICK_NONE))
++        {
++            if (menu_item_ptr->identifier.a_void != NULL)
++            {
++                if (curletter == menu_item_ptr->accelerator)
++                {
++                    if (curpage != menu_item_ptr->page_num)
++                    {
++                        curpage = menu_item_ptr->page_num;
++                        menu_display_page(menu, win, curpage);
++                    }
++                    menu_select_deselect(win, menu_item_ptr, INVERT);
++                    if (how == PICK_ONE)
++                    {
++                        num_selected = 1;
++                        dismiss = TRUE;
++                    }
++                    break;
++                }
++            }
++            menu_item_ptr = menu_item_ptr->next_item;
++        }
++    }
++    
++    if ((how == PICK_ANY) && (num_selected != -1))
++    {
++        num_selected = 0;
++        menu_item_ptr = menu->entries;
++        
++        while (menu_item_ptr != NULL)
++        {
++            if (menu_item_ptr->identifier.a_void != NULL)
++            {
++                if (menu_item_ptr->selected)
++                {
++                    num_selected++;
++                }
++            }
++            menu_item_ptr = menu_item_ptr->next_item;
++        }
++    }
++    
++    return num_selected;
++}
++
++
++/* Select, deselect, or toggle selected for the given menu entry */
++
++static void menu_select_deselect(WINDOW *win, nhmenu_item *item, menu_op operation)
++{
++    if ((operation == DESELECT) || (item->selected && (operation ==
++     INVERT)))
++    {
++        item->selected = FALSE;
++        mvwaddch(win, item->line_num + 1, 1, ' ');
++        mvwaddch(win, item->line_num + 1, 3, ')');
++    }
++    else
++    {
++        item->selected = TRUE;
++        curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
++        mvwaddch(win, item->line_num + 1, 1, '<');
++        mvwaddch(win, item->line_num + 1, 3, '>');
++        curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
++    }
++    
++    wrefresh(win);
++}
++
++
++/* Perform the selected operation (select, unselect, invert selection)
++on the given menu page.  If menu_page is 0, then perform opetation on
++all pages in menu.  Returns last page displayed.  */
++
++static int menu_operation(WINDOW *win, nhmenu *menu, menu_op
++ operation, int page_num)
++{
++    int first_page, last_page, current_page;
++    nhmenu_item *menu_item_ptr = menu->entries;    
++    
++    if (page_num == 0)  /* Operation to occur on all pages */
++    {
++        first_page = 1;
++        last_page = menu->num_pages;
++    }
++    else
++    {
++        first_page = page_num;
++        last_page = page_num;
++    }
++
++    /* Cycle through entries until we are on the correct page */
++
++    while (menu_item_ptr != NULL)
++    {
++        if (menu_item_ptr->page_num == first_page)
++        {
++            break;
++        }
++        menu_item_ptr = menu_item_ptr->next_item;
++    }
++    
++    current_page = first_page;
++    
++    if (page_num == 0)
++    {
++        menu_display_page(menu, win, current_page);
++    }
++    
++    if (menu_item_ptr == NULL)  /* Page not found */
++    {
++        panic("menu_display_page: attempt to display nonexistant page");
++    }
++    
++    while (menu_item_ptr != NULL)
++    {        
++        if (menu_item_ptr->page_num != current_page)
++        {
++            if (menu_item_ptr->page_num > last_page)
++            {
++                break;
++            }
++
++            current_page = menu_item_ptr->page_num;
++            menu_display_page(menu, win, current_page);
++        }
++        
++        if (menu_item_ptr->identifier.a_void != NULL)
++        {
++            menu_select_deselect(win, menu_item_ptr, operation);
++        }
++        
++        menu_item_ptr = menu_item_ptr->next_item;
++    }
++    
++    return current_page;
++}
+diff -burN nethack-3.4.3/win/curses/cursdial.h nethack/win/curses/cursdial.h
+--- nethack-3.4.3/win/curses/cursdial.h	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursdial.h	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,89 @@
++#ifndef CURSDIAL_H
++#define CURSDIAL_H
++
++
++/* Global declarations */
++
++void curses_line_input_dialog(const char *prompt, char *answer, int buffer);
++
++int curses_character_input_dialog(const char *prompt, const char *choices, CHAR_P def);
++
++int curses_ext_cmd(void);
++
++void curses_create_nhmenu(winid wid);
++
++void curses_add_nhmenu_item(winid wid, const ANY_P *identifier,
++ CHAR_P accelerator, CHAR_P group_accel, int attr, const char *str,
++ BOOLEAN_P presel);
++
++void curses_finalize_nhmenu(winid wid, const char *prompt);
++
++int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P **_selected);
++
++boolean curses_menu_exists(winid wid);
++
++void curses_del_menu(winid wid);
++
++
++/* Private declarations */
++
++typedef struct nhmi
++{
++    winid wid;  /* NetHack window id */
++    anything identifier; /* Value returned if item selected */
++    CHAR_P accelerator;  /* Character used to select item from menu */
++    CHAR_P group_accel; /* Group accelerator for menu item, if any */
++    int attr;  /* Text attributes for item */
++    const char *str;  /* Text of menu item */
++    BOOLEAN_P presel; /* Whether menu item should be preselected */
++    boolean selected;   /* Whether item is currently selected */
++    int page_num;   /* Display page number for entry */
++    int line_num;   /* Line number on page where entry begins */
++    int num_lines;  /* Number of lines entry uses on page */
++    struct nhmi *prev_item;    /* Pointer to previous entry */
++    struct nhmi *next_item;    /* Pointer to next entry */
++} nhmenu_item;
++
++typedef struct nhm
++{
++    winid wid;  /* NetHack window id */
++    const char *prompt;  /* Menu prompt text */
++    nhmenu_item *entries;   /* Menu entries */
++    int num_entries;          /* Number of menu entries */
++    int num_pages;            /* Number of display pages for entry */
++    int height;               /* Window height of menu */
++    int width;                /* Window width of menu */
++    struct nhm *prev_menu;    /* Pointer to previous entry */
++    struct nhm *next_menu;    /* Pointer to next entry */
++} nhmenu;
++
++typedef enum menu_op_type
++{
++    SELECT,
++    DESELECT,
++    INVERT
++} menu_op;
++
++static nhmenu *get_menu(winid wid);
++
++static char menu_get_accel(boolean first);
++
++static void menu_determine_pages(nhmenu *menu);
++
++static boolean menu_is_multipage(nhmenu *menu, int width, int height);
++
++static void menu_win_size(nhmenu *menu);
++
++static void menu_display_page(nhmenu *menu, WINDOW *win, int page_num);
++
++static int menu_get_choices(nhmenu *menu, int how);
++
++static int menu_get_selections(WINDOW *win, nhmenu *menu, int num_choices, int how);
++
++static void menu_select_deselect(WINDOW *win, nhmenu_item *item, menu_op operation);
++
++static int menu_operation(WINDOW *win, nhmenu *menu, menu_op operation,
++ int page_num);
++
++
++#endif  /* CURSDIAL_H */
+diff -burN nethack-3.4.3/win/curses/cursinit.c nethack/win/curses/cursinit.c
+--- nethack-3.4.3/win/curses/cursinit.c	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursinit.c	2009-03-11 15:08:53.000000000 -0400
+@@ -0,0 +1,792 @@
++#include "curses.h"
++#include "hack.h"
++#include "wincurs.h"
++#include "cursinit.h"
++
++/* Initialization functions for curses interface */
++
++
++/* Create the "main" nonvolitile windows used by nethack */
++
++void curses_create_main_windows()
++{
++    int message_x, message_y, status_x, status_y, map_x, map_y;
++    int message_height, message_width, status_height, status_width,
++     map_height, map_width;
++    int min_message_height = 1;
++    int message_orientation = 0;
++    int status_orientation = 0;
++    int border_space = 0;
++    int hspace = term_cols - 80;
++    boolean borders = FALSE;
++
++    switch (iflags.wc2_windowborders)
++    {
++        case 1: /* On */
++        {
++            borders = TRUE;
++            break;
++        }
++        case 2: /* Off */
++        {
++            borders = FALSE;
++            break;
++        }
++        case 3: /* Auto */
++        {
++            if ((term_cols > 81) && (term_rows > 25))
++            {
++                borders = TRUE;
++            }
++            break;
++        }
++        default:
++        {
++            borders = FALSE;
++        }
++    }
++
++    
++    if (borders)
++    {
++        border_space = 2;
++        hspace -= border_space;
++    }
++    
++    if ((term_cols - border_space) < COLNO)
++    {
++        min_message_height++;
++    }
++    
++    /* Determine status window orientation */    
++    if (!iflags.wc_align_status || (iflags.wc_align_status == ALIGN_TOP)
++     || (iflags.wc_align_status == ALIGN_BOTTOM))
++    {
++        if (!iflags.wc_align_status)
++        {
++            iflags.wc_align_status = ALIGN_BOTTOM;
++        }
++        status_orientation = iflags.wc_align_status;
++    }
++    else    /* left or right alignment */
++    {
++        /* Max space for player name and title horizontally */
++        if ((hspace >= 26) && (term_rows >= 24))
++        {
++            status_orientation = iflags.wc_align_status;
++            hspace -= (26 + border_space);
++        }
++        else
++        {
++            status_orientation = ALIGN_BOTTOM;
++        }
++    }
++    
++    /* Determine message window orientation */    
++    if (!iflags.wc_align_message || (iflags.wc_align_message == ALIGN_TOP)
++     || (iflags.wc_align_message == ALIGN_BOTTOM))
++    {
++        if (!iflags.wc_align_message)
++        {
++            iflags.wc_align_message = ALIGN_TOP;
++        }
++        message_orientation = iflags.wc_align_message;
++    }
++    else    /* left or right alignment */
++    {
++        if ((hspace - border_space) >= 25)   /* Arbitrary */
++        {
++            message_orientation = iflags.wc_align_message;
++        }
++        else
++        {
++            message_orientation = ALIGN_TOP;
++        }
++    }
++    
++    /* Determine window placement and size - 16 possible combos
++       If anyone wants to try to generalize this, be my guest! */
++    if ((status_orientation == ALIGN_TOP) &&
++     (message_orientation == ALIGN_TOP))
++    {
++        status_x = 0;
++        status_y = 0;
++        status_width = (term_cols - border_space);
++        status_height = 2;
++        message_x = 0;
++        message_y = status_y + (status_height + border_space);
++        message_width = (term_cols - border_space);
++        message_height = term_rows - (status_height + ROWNO + (border_space * 3));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        map_x = 0;
++        map_y = message_y + (message_height + border_space);
++        map_width = (term_cols - border_space);
++        map_height = term_rows - (status_height + message_height + (border_space * 3));
++    }
++    else if ((status_orientation == ALIGN_TOP) &&
++     (message_orientation == ALIGN_RIGHT))
++    {
++        status_x = 0;
++        status_y = 0;
++        status_height = 2;
++        message_height = (term_rows - border_space);
++        message_width = term_cols - (COLNO + (border_space * 2));
++        status_width = term_cols - (message_width + (border_space * 2));
++        message_x = status_x + (status_width + border_space);
++        message_y = 0;
++        map_x = 0;
++        map_y = status_y + (status_height + border_space);
++        map_width = status_width;
++        map_height = term_rows - (status_height + (border_space * 2));
++    }
++    else if ((status_orientation == ALIGN_TOP) &&
++     (message_orientation == ALIGN_BOTTOM))
++    {
++        status_x = 0;
++        status_y = 0;
++        status_width = (term_cols - border_space);
++        status_height = 2;
++        map_x = 0;
++        map_y = status_y + (status_height + border_space);
++        map_width = (term_cols - border_space);
++        message_height = term_rows - (status_height + ROWNO + (border_space * 3));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        map_height = term_rows - (status_height + message_height + (border_space * 3));
++        message_x = 0;
++        message_y = map_y + (map_height + border_space);
++        message_width = (term_cols - border_space);
++    }
++    else if ((status_orientation == ALIGN_TOP) &&
++     (message_orientation == ALIGN_LEFT))
++    {
++        message_x = 0;
++        message_y = 0;
++        message_height = (term_rows - border_space);
++        message_width = term_cols - (COLNO + (border_space * 2));
++        status_x = message_x + (message_width + border_space);
++        status_y = 0;
++        status_height = 2;
++        status_width = term_cols - (message_width + (border_space * 2));
++        map_x = status_x;
++        map_y = status_y + (status_height + border_space);
++        map_height = term_rows - (status_height + (border_space * 2));
++        map_width = status_width;
++    }
++    if ((status_orientation == ALIGN_RIGHT) &&
++     (message_orientation == ALIGN_TOP))
++    {
++        status_width = 26;
++        status_height = (term_rows - border_space);
++        status_x = term_cols - (status_width + border_space);
++        status_y = 0;
++        message_x = 0;
++        message_y = 0;
++        message_width = term_cols - (status_width + (border_space * 2));
++        message_height = term_rows - (ROWNO + (border_space * 2));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        map_x = 0;
++        map_y = message_y + (message_height + border_space);
++        map_width = term_cols - (status_width + (border_space * 2));
++        map_height = term_rows - (message_height + (border_space * 2));
++    }
++    else if ((status_orientation == ALIGN_RIGHT) &&
++     (message_orientation == ALIGN_RIGHT))
++    {
++        map_x = 0;
++        map_y = 0;
++        map_height = (term_rows - border_space);
++        status_width = 26;
++        message_width = term_cols - (COLNO + status_width + (border_space * 3));
++        map_width = term_cols - (status_width + message_width + (border_space * 3));
++        message_x = map_x + (map_width + border_space);
++        message_y = 0;
++        message_height = (term_rows - border_space);
++        status_x = message_x + (message_width + border_space);
++        status_y = 0;
++        status_height = (term_rows - border_space);
++    }
++    else if ((status_orientation == ALIGN_RIGHT) &&
++     (message_orientation == ALIGN_BOTTOM))
++    {
++        map_x = 0;
++        map_y = 0;
++        status_width = 26;
++        map_width = term_cols - (status_width + (border_space * 2));
++        message_height = term_rows - (ROWNO + (border_space * 2));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        map_height = term_rows - (message_height + (border_space * 2));
++        message_x = 0;
++        message_y = map_y + (map_height + border_space);
++        message_width = map_width;
++        status_x = map_x + (map_width + border_space);
++        status_y = 0;
++        status_height = (term_rows - border_space);
++    }
++    else if ((status_orientation == ALIGN_RIGHT) &&
++     (message_orientation == ALIGN_LEFT))
++    {
++        status_x = 0;
++        status_y = 0;
++        status_height = (term_rows - border_space);
++        status_width = 26;
++        message_width = term_cols - (status_width + COLNO + (border_space * 3));
++        map_x = status_x + (status_width + border_space);
++        map_y = 0;
++        map_height = (term_rows - border_space);
++        map_width = term_cols - (status_width + message_width + (border_space * 3));
++        message_x = map_x + (map_width + border_space);
++        message_y = 0;
++        message_height = (term_rows - border_space);
++    }
++    if ((status_orientation == ALIGN_BOTTOM) &&
++     (message_orientation == ALIGN_TOP))
++    {
++        message_x = 0;
++        message_y = 0;
++        message_width = (term_cols - border_space);
++        status_height = 2;
++        message_height = term_rows - (status_height + ROWNO + (border_space * 3));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        map_x = 0;
++        map_y = message_y + (message_height + border_space);
++        map_width = (term_cols - border_space);
++        map_height = term_rows - (status_height + message_height + (border_space * 3));
++        status_x = 0;
++        status_y = map_y + (map_height + border_space);
++        status_width = (term_cols - border_space);
++    }
++    else if ((status_orientation == ALIGN_BOTTOM) &&
++     (message_orientation == ALIGN_RIGHT))
++    {
++        map_x = 0;
++        map_y = 0;
++        status_height = 2;
++        map_height = term_rows - (status_height + (border_space * 2));
++        message_width = term_cols - (COLNO + (border_space * 2));
++        map_width = term_cols - (message_width + (border_space * 2));
++        status_x = 0;
++        status_y = map_y + (map_height + border_space);
++        status_width = map_width;
++        message_x = map_x + (map_width + border_space);
++        message_y = 0;
++        message_height = (term_rows - border_space);
++    }
++    else if ((status_orientation == ALIGN_BOTTOM) &&
++     (message_orientation == ALIGN_BOTTOM))
++    {
++        map_x = 0;
++        map_y = 0;
++        message_x = 0;
++        status_x = 0;
++        message_width = (term_cols - border_space);
++        status_height = 2;
++        message_height = term_rows - (status_height + ROWNO + (border_space * 3));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        map_width = (term_cols - border_space);
++        map_height = term_rows - (status_height + message_height + (border_space * 3));
++        message_y = map_y + (map_height + border_space);
++        status_y = message_y + (message_height + border_space);
++        status_width = (term_cols - border_space);
++    }
++    else if ((status_orientation == ALIGN_BOTTOM) &&
++     (message_orientation == ALIGN_LEFT))
++    {
++        message_x = 0;
++        message_y = 0;
++        message_height = (term_rows - border_space);
++        message_width = term_cols - (COLNO + (border_space * 2));
++        status_height = 2;
++        map_x = message_x + (message_width + border_space);
++        map_y = 0;
++        map_height = term_rows - (status_height + (border_space * 2));
++        map_width = term_cols - (message_width + (border_space * 2));
++        status_x = map_x;
++        status_y = map_y + (map_height + border_space);
++        status_width = term_cols - (message_width + (border_space * 2));
++    }
++    if ((status_orientation == ALIGN_LEFT) &&
++     (message_orientation == ALIGN_TOP))
++    {
++        status_x = 0;
++        status_y = 0;
++        status_height = (term_rows - border_space);
++        status_width = 26;
++        message_x = status_x + (status_width + border_space);
++        message_y = 0;
++        message_height = term_rows - (ROWNO + (border_space * 2));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        message_width = term_cols - (status_width + (border_space * 2));
++        map_x = message_x;
++        map_y = message_y + (message_height + border_space);
++        map_height = term_rows - (message_height + (border_space * 2));
++        map_width = term_cols - (status_width + (border_space * 2));
++    }
++    else if ((status_orientation == ALIGN_LEFT) &&
++     (message_orientation == ALIGN_RIGHT))
++    {
++        message_x = 0;
++        message_y = 0;
++        message_height = (term_rows - border_space);
++        status_width = 26;
++        message_width = term_cols - (status_width + COLNO + (border_space * 3));
++        map_x = message_x + (message_width + border_space);
++        map_y = 0;
++        map_height = (term_rows - border_space);
++        map_width = term_cols - (status_width + message_width + (border_space * 3));
++        status_x = map_x + (map_width + border_space);
++        status_y = 0;
++        status_height = (term_rows - border_space);
++    }
++    else if ((status_orientation == ALIGN_LEFT) &&
++     (message_orientation == ALIGN_BOTTOM))
++    {
++        status_x = 0;
++        status_y = 0;
++        status_height = (term_rows - border_space);
++        status_width = 26;
++        map_x = status_x + (status_width + border_space);
++        map_y = 0;
++        message_height = term_rows - (ROWNO + (border_space * 2));
++        if (message_height < min_message_height)
++        {
++            message_height = min_message_height;
++        }
++        map_height = term_rows - (message_height + (border_space * 2));
++        map_width = term_cols - (status_width + (border_space * 2));
++        message_x = status_x + (status_width + border_space);
++        message_y = map_y + (map_height + border_space);
++        message_width = map_width;
++    }
++    else if ((status_orientation == ALIGN_LEFT) &&
++     (message_orientation == ALIGN_LEFT))
++    {
++        status_x = 0;
++        status_y = 0;
++        status_height = (term_rows - border_space);
++        status_width = 26;
++        message_x = status_x + (status_width + border_space);
++        message_y = 0;
++        message_height = status_height;
++        message_width = term_cols - (COLNO + status_width + (border_space * 3));
++        map_x = message_x + (message_width + border_space);
++        map_y = 0;
++        map_height = message_height;
++        map_width = term_cols - (status_width + message_width + (border_space * 3));
++    }
++    
++    if (map_width > COLNO)
++    {
++        map_width = COLNO;
++    }
++    
++    if (map_height > ROWNO)
++    {
++        map_height = ROWNO;
++    }
++    
++    if (curses_window_exists(STATUS_WIN))
++    {
++        curses_del_nhwin(STATUS_WIN);
++        curses_del_nhwin(MESSAGE_WIN);
++        curses_del_nhwin(MAP_WIN);
++        clear();
++    }
++    
++    curses_add_nhwin(STATUS_WIN, status_height, status_width, status_y,
++     status_x, status_orientation, borders);
++
++    curses_add_nhwin(MESSAGE_WIN, message_height, message_width, message_y,
++     message_x, message_orientation, borders);
++
++    if (borders)
++    {
++        mapborderwin = newwin(map_height + border_space, map_width
++         + border_space, map_y, map_x);
++        wrefresh(mapborderwin);
++        curses_add_nhwin(MAP_WIN, map_height, map_width, map_y + 1, map_x + 1,
++         0, borders);
++    }
++    else
++    {
++        curses_add_nhwin(MAP_WIN, map_height, map_width, map_y, map_x, 0,
++         borders);
++    }
++
++    refresh();
++    curses_refresh_nethack_windows();
++
++    if (iflags.window_inited)
++    {
++        curses_update_stats();
++    }
++    else
++    {
++        iflags.window_inited = TRUE;
++    }
++}
++
++
++/* Initialize curses colors to colors used by NetHack */
++
++void curses_init_nhcolors()
++{
++#ifdef TEXTCOLOR
++    if (has_colors())
++    {
++#ifdef NCURSES_VERSION
++        use_default_colors();
++        init_pair(1, COLOR_BLACK, -1);
++        init_pair(2, COLOR_RED, -1);
++        init_pair(3, COLOR_GREEN, -1);
++        init_pair(4, COLOR_YELLOW, -1);
++        init_pair(5, COLOR_BLUE, -1);
++        init_pair(6, COLOR_MAGENTA, -1);
++        init_pair(7, COLOR_CYAN, -1);
++        init_pair(8, -1, -1);
++        init_pair(9, COLOR_WHITE, -1);
++#else        
++        init_pair(1, COLOR_BLACK, COLOR_BLACK);
++        init_pair(2, COLOR_RED, COLOR_BLACK);
++        init_pair(3, COLOR_GREEN, COLOR_BLACK);
++        init_pair(4, COLOR_YELLOW, COLOR_BLACK);
++        init_pair(5, COLOR_BLUE, COLOR_BLACK);
++        init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
++        init_pair(7, COLOR_CYAN, COLOR_BLACK);
++        init_pair(8, COLOR_WHITE, COLOR_BLACK);
++#endif
++        if (can_change_color())
++        {
++            init_color(COLOR_YELLOW, 500, 300, 0);
++            init_color(COLOR_WHITE, 600, 600, 600);
++        }
++    }
++#endif
++}
++
++
++/* Allow player to pick character's role, race, gender, and alignment.
++Borrowed from the Gnome window port. */
++
++void curses_choose_character()
++{
++    int n, i, sel;
++    const char** choices;
++    int* pickmap;
++
++    /* prevent an unnecessary prompt */
++    rigid_role_checks();
++
++    if (!flags.randomall && flags.initrole < 0) {
++
++	/* select a role */
++	for (n = 0; roles[n].name.m; n++) continue;
++	choices = (const char **)alloc(sizeof(char *) * (n+1));
++	pickmap = (int*)alloc(sizeof(int) * (n+1));
++	for (;;) {
++	    for (n = 0, i = 0; roles[i].name.m; i++) {
++		if (ok_role(i, flags.initrace,
++			    flags.initgend, flags.initalign)) {
++		    if (flags.initgend >= 0 && flags.female && roles[i].name.f)
++			choices[n] = roles[i].name.f;
++		    else
++			choices[n] = roles[i].name.m;
++		    pickmap[n++] = i;
++		}
++	    }
++	    if (n > 0) break;
++	    else if (flags.initalign >= 0) flags.initalign = -1;    /* reset */
++	    else if (flags.initgend >= 0) flags.initgend = -1;
++	    else if (flags.initrace >= 0) flags.initrace = -1;
++	    else panic("no available ROLE+race+gender+alignment combinations");
++	}
++	choices[n] = (const char *) 0;
++	if (n > 1)
++        sel = curses_character_dialog(choices, "Choose one of the following roles:");
++	else sel = 0;
++	if (sel >= 0) sel = pickmap[sel];
++	else if (sel == ROLE_NONE) {		/* Quit */
++	    clearlocks();
++	    curses_bail(0);
++	}
++	free(choices);
++	free(pickmap);
++    } else if (flags.initrole < 0) sel = ROLE_RANDOM;
++    else sel = flags.initrole;
++  
++    if (sel == ROLE_RANDOM) {	/* Random role */
++	sel = pick_role(flags.initrace, flags.initgend,
++			  flags.initalign, PICK_RANDOM);
++	if (sel < 0) sel = randrole();
++    }
++
++    flags.initrole = sel;
++
++    /* Select a race, if necessary */
++    /* force compatibility with role, try for compatibility with
++     * pre-selected gender/alignment */
++    if (flags.initrace < 0 || !validrace(flags.initrole, flags.initrace)) {
++	if (flags.initrace == ROLE_RANDOM || flags.randomall) {
++	    flags.initrace = pick_race(flags.initrole, flags.initgend,
++				       flags.initalign, PICK_RANDOM);
++	    if (flags.initrace < 0) flags.initrace = randrace(flags.initrole);
++	} else {
++	    /* Count the number of valid races */
++	    n = 0;	/* number valid */
++	    for (i = 0; races[i].noun; i++) {
++		if (ok_race(flags.initrole, i, flags.initgend, flags.initalign))
++		    n++;
++	    }
++	    if (n == 0) {
++		for (i = 0; races[i].noun; i++) {
++		    if (validrace(flags.initrole, i)) n++;
++		}
++	    }
++
++	    choices = (const char **)alloc(sizeof(char *) * (n+1));
++	    pickmap = (int*)alloc(sizeof(int) * (n + 1));
++	    for (n = 0, i = 0; races[i].noun; i++) {
++		if (ok_race(flags.initrole, i, flags.initgend,
++			    flags.initalign)) {
++		    choices[n] = races[i].noun;
++		    pickmap[n++] = i;
++		}
++	    }
++	    choices[n] = (const char *) 0;
++	    /* Permit the user to pick, if there is more than one */
++	    if (n > 1)
++		sel = curses_character_dialog(choices, "Choose one of the following races:");
++	    else sel = 0;
++	    if (sel >= 0) sel = pickmap[sel];
++	    else if (sel == ROLE_NONE) { /* Quit */
++		clearlocks();
++		curses_bail(0);
++	    }
++	    flags.initrace = sel;
++	    free(choices);
++	    free(pickmap);
++	}
++	if (flags.initrace == ROLE_RANDOM) {	/* Random role */
++	    sel = pick_race(flags.initrole, flags.initgend,
++			    flags.initalign, PICK_RANDOM);
++	    if (sel < 0) sel = randrace(flags.initrole);
++	    flags.initrace = sel;
++	}
++    }
++
++    /* Select a gender, if necessary */
++    /* force compatibility with role/race, try for compatibility with
++     * pre-selected alignment */
++    if (flags.initgend < 0 ||
++	!validgend(flags.initrole, flags.initrace, flags.initgend)) {
++	if (flags.initgend == ROLE_RANDOM || flags.randomall) {
++	    flags.initgend = pick_gend(flags.initrole, flags.initrace,
++				       flags.initalign, PICK_RANDOM);
++	    if (flags.initgend < 0)
++		flags.initgend = randgend(flags.initrole, flags.initrace);
++	} else {
++	    /* Count the number of valid genders */
++	    n = 0;	/* number valid */
++	    for (i = 0; i < ROLE_GENDERS; i++) {
++		if (ok_gend(flags.initrole, flags.initrace, i, flags.initalign))
++		    n++;
++	    }
++	    if (n == 0) {
++		for (i = 0; i < ROLE_GENDERS; i++) {
++		    if (validgend(flags.initrole, flags.initrace, i)) n++;
++		}
++	    }
++
++	    choices = (const char **)alloc(sizeof(char *) * (n+1));
++	    pickmap = (int*)alloc(sizeof(int) * (n + 1));
++	    for (n = 0, i = 0; i < ROLE_GENDERS; i++) {
++		if (ok_gend(flags.initrole, flags.initrace, i,
++				flags.initalign)) {
++		    choices[n] = genders[i].adj;
++		    pickmap[n++] = i;
++		}
++	    }
++	    choices[n] = (const char *) 0;
++	    /* Permit the user to pick, if there is more than one */
++	    if (n > 1)
++		sel = curses_character_dialog(choices, "Choose one of the following genders:");
++	    else sel = 0;
++	    if (sel >= 0) sel = pickmap[sel];
++	    else if (sel == ROLE_NONE) { /* Quit */
++		clearlocks();
++		curses_bail(0);
++	    }
++	    flags.initgend = sel;
++	    free(choices);
++	    free(pickmap);
++	}
++	if (flags.initgend == ROLE_RANDOM) {	/* Random gender */
++	    sel = pick_gend(flags.initrole, flags.initrace,
++			    flags.initalign, PICK_RANDOM);
++	    if (sel < 0) sel = randgend(flags.initrole, flags.initrace);
++	    flags.initgend = sel;
++	}
++    }
++
++    /* Select an alignment, if necessary */
++    /* force compatibility with role/race/gender */
++    if (flags.initalign < 0 ||
++	!validalign(flags.initrole, flags.initrace, flags.initalign)) {
++	if (flags.initalign == ROLE_RANDOM || flags.randomall) {
++	    flags.initalign = pick_align(flags.initrole, flags.initrace,
++					 flags.initgend, PICK_RANDOM);
++	    if (flags.initalign < 0)
++		flags.initalign = randalign(flags.initrole, flags.initrace);
++	} else {
++	    /* Count the number of valid alignments */
++	    n = 0;	/* number valid */
++	    for (i = 0; i < ROLE_ALIGNS; i++) {
++		if (ok_align(flags.initrole, flags.initrace, flags.initgend, i))
++		    n++;
++	    }
++	    if (n == 0) {
++		for (i = 0; i < ROLE_ALIGNS; i++)
++		    if (validalign(flags.initrole, flags.initrace, i)) n++;
++	    }
++
++	    choices = (const char **)alloc(sizeof(char *) * (n+1));
++	    pickmap = (int*)alloc(sizeof(int) * (n + 1));
++	    for (n = 0, i = 0; i < ROLE_ALIGNS; i++) {
++		if (ok_align(flags.initrole,
++			     flags.initrace, flags.initgend, i)) {
++		    choices[n] = aligns[i].adj;
++		    pickmap[n++] = i;
++		}
++	    }
++	    choices[n] = (const char *) 0;
++	    /* Permit the user to pick, if there is more than one */
++	    if (n > 1)
++		sel = curses_character_dialog(choices, "Choose one of the following alignments:");
++	    else sel = 0;
++	    if (sel >= 0) sel = pickmap[sel];
++	    else if (sel == ROLE_NONE) { /* Quit */
++		clearlocks();
++		curses_bail(0);
++	    }
++	    flags.initalign = sel;
++	    free(choices);
++	    free(pickmap);
++	}
++	if (flags.initalign == ROLE_RANDOM) {
++	    sel = pick_align(flags.initrole, flags.initrace,
++			     flags.initgend, PICK_RANDOM);
++	    if (sel < 0) sel = randalign(flags.initrole, flags.initrace);
++	    flags.initalign = sel;
++	}
++    }
++}
++
++
++/* Prompt user for character race, role, alignment, or gender */
++
++int curses_character_dialog(const char** choices, const char *prompt)
++{
++    int count, count2, ret, curletter;
++    char used_letters[52];
++    anything identifier;
++    menu_item *selected = NULL;
++    winid wid = curses_get_wid(NHW_MENU);
++
++    identifier.a_void = 0;
++    curses_start_menu(wid);
++
++    for (count=0; choices[count]; count++)
++    {
++        curletter=tolower(choices[count][0]);
++        for (count2=0; count2<count; count2++)
++        {
++            if (curletter==used_letters[count2])
++            {
++                curletter=toupper(curletter);
++            }
++        }
++
++        identifier.a_int = (count + 1); /* Must be non-zero */
++        curses_add_menu(wid, NO_GLYPH, &identifier, curletter, 0,
++         A_NONE, choices[count], FALSE);
++        used_letters[count] = curletter;
++    }
++
++    /* Random Selection */
++    identifier.a_int = ROLE_RANDOM;
++    curses_add_menu(wid, NO_GLYPH, &identifier, '*', 0, A_NONE, "Random",
++     FALSE);    
++    
++    /* Quit prompt */
++    identifier.a_int = ROLE_NONE;
++    curses_add_menu(wid, NO_GLYPH, &identifier, 'q', 0, A_NONE, "Quit",
++     FALSE);    
++    curses_end_menu(wid, prompt);
++    ret = curses_select_menu(wid, PICK_ONE, &selected);
++    ret = (selected->item.a_int);
++
++    if (ret > 0)
++    {
++        ret--;
++    }
++    
++    free(selected);
++    return ret;
++}
++
++
++/* Initialize and display options appropriately */
++
++void curses_init_options()
++{
++	set_wc_option_mod_status(WC_ALIGN_MESSAGE|WC_ALIGN_STATUS|WC_COLOR|
++	 WC_HILITE_PET|WC_POPUP_DIALOG, SET_IN_GAME);
++	set_wc2_option_mod_status(WC2_TERM_COLS|WC2_TERM_ROWS|
++	 WC2_WINDOWBORDERS, SET_IN_GAME);
++	set_option_mod_status("DECgraphics", SET_IN_FILE);
++	set_option_mod_status("perm_invent", SET_IN_FILE);
++	set_option_mod_status("eight_bit_tty", SET_IN_FILE);
++#ifdef PDCURSES
++    /* PDCurses for SDL, win32 and OS/2 has the ability to set the
++     terminal size programatically.  If the user does not specify a
++     size in the config file, we will set it to a nice big 110x32 to
++     take advantage of some of the nice features of this windowport. */
++    if (iflags.wc2_term_cols == 0)
++    {
++        iflags.wc2_term_cols = 110;
++    }
++    
++    if (iflags.wc2_term_rows == 0)
++    {
++        iflags.wc2_term_rows = 32;
++    }
++    
++    resize_term(iflags.wc2_term_rows, iflags.wc2_term_cols);
++    getmaxyx(base_term, term_rows, term_cols);
++#endif
++    if (!iflags.wc2_windowborders)
++    {
++        iflags.wc2_windowborders = 3; /* Set to auto if not specified */
++    }
++}
++
+diff -burN nethack-3.4.3/win/curses/cursinit.h nethack/win/curses/cursinit.h
+--- nethack-3.4.3/win/curses/cursinit.h	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursinit.h	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,17 @@
++#ifndef CURSINIT_H
++#define CURSINIT_H
++
++/* Global declarations */
++
++void curses_create_main_windows(void);
++
++void curses_init_nhcolors(void);
++
++void curses_choose_character(void);
++
++int curses_character_dialog(const char** choices, const char *prompt);
++
++void curses_init_options(void);
++
++
++#endif  /* CURSINIT_H */
+diff -burN nethack-3.4.3/win/curses/cursmain.c nethack/win/curses/cursmain.c
+--- nethack-3.4.3/win/curses/cursmain.c	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursmain.c	2009-03-11 15:08:53.000000000 -0400
+@@ -0,0 +1,650 @@
++#include "curses.h"
++#include "hack.h"
++#include "wincurs.h"
++
++/* Public functions for curses NetHack interface */
++
++/* Interface definition, for windows.c */
++struct window_procs curses_procs = {
++    "curses",
++    WC_ALIGN_MESSAGE|WC_ALIGN_STATUS|WC_COLOR|WC_HILITE_PET|
++    WC_POPUP_DIALOG,
++    WC2_TERM_COLS|WC2_TERM_ROWS|WC2_WINDOWBORDERS,
++    curses_init_nhwindows,
++    curses_player_selection,
++    curses_askname,
++    curses_get_nh_event,
++    curses_exit_nhwindows,
++    curses_suspend_nhwindows,
++    curses_resume_nhwindows,
++    curses_create_nhwindow,
++    curses_clear_nhwindow,
++    curses_display_nhwindow,
++    curses_destroy_nhwindow,
++    curses_curs,
++    curses_putstr,
++    curses_display_file,
++    curses_start_menu,
++    curses_add_menu,
++    curses_end_menu,
++    curses_select_menu,
++    genl_message_menu,
++    curses_update_inventory,
++    curses_mark_synch,
++    curses_wait_synch,
++#ifdef CLIPPING
++    curses_cliparound,
++#endif
++#ifdef POSITIONBAR
++    donull,
++#endif
++    curses_print_glyph,
++    curses_raw_print,
++    curses_raw_print_bold,
++    curses_nhgetch,
++    curses_nh_poskey,
++    curses_nhbell,
++    curses_doprev_message,
++    curses_yn_function,
++    curses_getlin,
++    curses_get_ext_cmd,
++    curses_number_pad,
++    curses_delay_output,
++#ifdef CHANGE_COLOR	/* only a Mac option currently */
++    donull,
++    donull,
++#endif
++    curses_start_screen,
++    curses_end_screen,
++    genl_outrip,
++    curses_preference_update,
++};
++
++/*  
++init_nhwindows(int* argcp, char** argv)
++                -- Initialize the windows used by NetHack.  This can also
++                   create the standard windows listed at the top, but does
++                   not display them.
++                -- Any commandline arguments relevant to the windowport
++                   should be interpreted, and *argcp and *argv should
++                   be changed to remove those arguments.
++                -- When the message window is created, the variable
++                   iflags.window_inited needs to be set to TRUE.  Otherwise
++                   all plines() will be done via raw_print().
++                ** Why not have init_nhwindows() create all of the "standard"
++                ** windows?  Or at least all but WIN_INFO?      -dean
++*/
++void curses_init_nhwindows(int* argcp, char** argv)
++{
++#ifdef XCURSES
++    base_term = Xinitscr(*argcp, argv);
++#else
++    base_term = initscr();
++#endif
++#ifdef TEXTCOLOR
++    if (has_colors())
++        start_color();
++    else
++        iflags.use_color = FALSE;
++    curses_init_nhcolors();
++#else
++    iflags.use_color = FALSE;
++#endif
++    noecho();
++    raw();
++    keypad(stdscr, TRUE);
++    meta(stdscr, TRUE);
++    curs_set(0);
++    getmaxyx(base_term, term_rows, term_cols);
++    curses_init_options();
++    if ((term_rows < 18) || (term_cols < 40))
++    {
++        panic("Terminal too small.  Must be minumum 40 width and 18 height");
++    }
++
++    curses_create_main_windows();
++    curses_init_mesg_history();
++}
++
++
++/* Do a window-port specific player type selection. If player_selection()
++   offers a Quit option, it is its responsibility to clean up and terminate
++   the process. You need to fill in pl_character[0].
++*/
++void curses_player_selection()
++{
++    curses_choose_character();
++}
++
++
++/* Ask the user for a player name. */
++void curses_askname()
++{
++    curses_line_input_dialog("Who are you?", plname, PL_NSIZ);
++}
++
++
++/* Does window event processing (e.g. exposure events).
++   A noop for the tty and X window-ports.
++*/
++void curses_get_nh_event()
++{
++#ifdef PDCURSES
++    if (is_termresized())
++    {
++        resize_term(0, 0);
++        getmaxyx(base_term, term_rows, term_cols);
++        curses_create_main_windows();
++        curses_last_messages();
++        doredraw();
++    }
++#endif
++#ifdef NCURSES_VERSION  /* Is there a better way to detect ncurses? */
++    if (is_term_resized(term_rows, term_cols))
++    {
++        if (!isendwin())
++        {
++            endwin();
++        }
++        
++        refresh();
++        getmaxyx(base_term, term_rows, term_cols);
++        curses_create_main_windows();
++        curses_last_messages();
++        doredraw();
++    }
++#endif
++}
++
++/* Exits the window system.  This should dismiss all windows,
++   except the "window" used for raw_print().  str is printed if possible.
++*/
++void curses_exit_nhwindows(const char *str)
++{
++    endwin();
++    iflags.window_inited = 0;
++    if (str != NULL)
++    {
++        raw_print(str);
++    }
++}
++
++/* Prepare the window to be suspended. */
++void curses_suspend_nhwindows(const char *str)
++{
++}
++
++
++/* Restore the windows after being suspended. */
++void curses_resume_nhwindows()
++{
++    curses_refresh_nethack_windows();
++}
++
++/*  Create a window of type "type" which can be 
++        NHW_MESSAGE     (top line)
++        NHW_STATUS      (bottom lines)
++        NHW_MAP         (main dungeon)
++        NHW_MENU        (inventory or other "corner" windows)
++        NHW_TEXT        (help/text, full screen paged window)
++*/
++winid curses_create_nhwindow(int type)
++{
++    winid wid = curses_get_wid(type);
++
++    if (curses_is_menu(wid) || curses_is_text(wid))
++    {
++        curses_start_menu(wid);
++        /* Add to window list just to keep track of the wid */
++        curses_add_nhwin(wid, 0, 0, 0, 0, 0, TRUE);
++    }
++    
++    return wid;
++}
++
++
++/* Clear the given window, when asked to. */
++void curses_clear_nhwindow(winid wid)
++{
++    if (wid != NHW_MESSAGE)
++    {
++        curses_clear_nhwin(wid);
++    }
++}
++
++/* -- Display the window on the screen.  If there is data
++                   pending for output in that window, it should be sent.
++                   If blocking is TRUE, display_nhwindow() will not
++                   return until the data has been displayed on the screen,
++                   and acknowledged by the user where appropriate.
++                -- All calls are blocking in the tty window-port.
++                -- Calling display_nhwindow(WIN_MESSAGE,???) will do a
++                   --more--, if necessary, in the tty window-port.
++*/
++void curses_display_nhwindow(winid wid, BOOLEAN_P block)
++{
++    menu_item *selected = NULL;
++    WINDOW *win = curses_get_nhwin(wid);
++    
++    if ((win != NULL) && (wid == MAP_WIN) && block)
++    {
++        curses_more();
++    }
++    else if (curses_is_menu(wid) || curses_is_text(wid))
++    {
++        curses_end_menu(wid, "");
++        curses_select_menu(wid, PICK_NONE, &selected);
++    }
++}
++
++
++/* Destroy will dismiss the window if the window has not 
++ * already been dismissed.
++*/
++void curses_destroy_nhwindow(winid wid)
++{
++    curses_del_nhwin(wid);
++}
++
++/* Next output to window will start at (x,y), also moves
++ displayable cursor to (x,y).  For backward compatibility,
++ 1 <= x < cols, 0 <= y < rows, where cols and rows are
++ the size of window.
++*/
++void curses_curs(winid wid, int x, int y)
++{
++    curses_move_cursor(wid, x, y);
++}
++
++/*
++putstr(window, attr, str)
++                -- Print str on the window with the given attribute.  Only
++                   printable ASCII characters (040-0126) must be supported.
++                   Multiple putstr()s are output on separate lines.
++Attributes
++                   can be one of
++                        ATR_NONE (or 0)
++                        ATR_ULINE
++                        ATR_BOLD
++                        ATR_BLINK
++                        ATR_INVERSE
++                   If a window-port does not support all of these, it may map
++                   unsupported attributes to a supported one (e.g. map them
++                   all to ATR_INVERSE).  putstr() may compress spaces out of
++                   str, break str, or truncate str, if necessary for the
++                   display.  Where putstr() breaks a line, it has to clear
++                   to end-of-line.
++                -- putstr should be implemented such that if two putstr()s
++                   are done consecutively the user will see the first and
++                   then the second.  In the tty port, pline() achieves this
++                   by calling more() or displaying both on the same line.
++*/
++void curses_putstr(winid wid, int attr, const char *text)
++{
++    curses_puts(wid, attr, text);
++}
++
++/* Display the file named str.  Complain about missing files
++                   iff complain is TRUE.
++*/
++void curses_display_file(const char *filename,BOOLEAN_P must_exist)
++{
++    curses_view_file(filename, must_exist);
++}
++
++/* Start using window as a menu.  You must call start_menu()
++   before add_menu().  After calling start_menu() you may not
++   putstr() to the window.  Only windows of type NHW_MENU may
++   be used for menus.
++*/
++void curses_start_menu(winid wid)
++{
++    curses_create_nhmenu(wid);
++}
++
++/*
++add_menu(winid wid, int glyph, const anything identifier,
++                                char accelerator, char groupacc,
++                                int attr, char *str, boolean preselected)
++                -- Add a text line str to the given menu window.  If identifier
++                   is 0, then the line cannot be selected (e.g. a title).
++                   Otherwise, identifier is the value returned if the line is
++                   selected.  Accelerator is a keyboard key that can be used
++                   to select the line.  If the accelerator of a selectable
++                   item is 0, the window system is free to select its own
++                   accelerator.  It is up to the window-port to make the
++                   accelerator visible to the user (e.g. put "a - " in front
++                   of str).  The value attr is the same as in putstr().
++                   Glyph is an optional glyph to accompany the line.  If
++                   window port cannot or does not want to display it, this
++                   is OK.  If there is no glyph applicable, then this
++                   value will be NO_GLYPH.
++                -- All accelerators should be in the range [A-Za-z].
++                -- It is expected that callers do not mix accelerator
++                   choices.  Either all selectable items have an accelerator
++                   or let the window system pick them.  Don't do both.
++                -- Groupacc is a group accelerator.  It may be any character
++                   outside of the standard accelerator (see above) or a
++                   number.  If 0, the item is unaffected by any group
++                   accelerator.  If this accelerator conflicts with
++                   the menu command (or their user defined alises), it loses.
++                   The menu commands and aliases take care not to interfere
++                   with the default object class symbols.
++                -- If you want this choice to be preselected when the
++                   menu is displayed, set preselected to TRUE.
++*/
++void curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
++		CHAR_P accelerator, CHAR_P group_accel, int attr, 
++		const char *str, BOOLEAN_P presel)
++{
++    curses_add_nhmenu_item(wid, identifier, accelerator, group_accel, attr,
++     str, presel);
++}
++
++/*
++end_menu(window, prompt)
++                -- Stop adding entries to the menu and flushes the window
++                   to the screen (brings to front?).  Prompt is a prompt
++                   to give the user.  If prompt is NULL, no prompt will
++                   be printed.
++                ** This probably shouldn't flush the window any more (if
++                ** it ever did).  That should be select_menu's job.  -dean
++*/
++void curses_end_menu(winid wid, const char *prompt)
++{
++    curses_finalize_nhmenu(wid, prompt);
++}
++
++/*
++int select_menu(winid window, int how, menu_item **selected)
++                -- Return the number of items selected; 0 if none were chosen,
++                   -1 when explicitly cancelled.  If items were selected, then
++                   selected is filled in with an allocated array of menu_item
++                   structures, one for each selected line.  The caller must
++                   free this array when done with it.  The "count" field
++                   of selected is a user supplied count.  If the user did
++                   not supply a count, then the count field is filled with
++                   -1 (meaning all).  A count of zero is equivalent to not
++                   being selected and should not be in the list.  If no items
++                   were selected, then selected is NULL'ed out.  How is the
++                   mode of the menu.  Three valid values are PICK_NONE,
++                   PICK_ONE, and PICK_N, meaning: nothing is selectable,
++                   only one thing is selectable, and any number valid items
++                   may selected.  If how is PICK_NONE, this function should
++                   never return anything but 0 or -1.
++                -- You may call select_menu() on a window multiple times --
++                   the menu is saved until start_menu() or destroy_nhwindow()
++                   is called on the window.
++                -- Note that NHW_MENU windows need not have select_menu()
++                   called for them. There is no way of knowing whether
++                   select_menu() will be called for the window at
++                   create_nhwindow() time.
++*/
++int curses_select_menu(winid wid, int how, MENU_ITEM_P **selected)
++{
++    return curses_display_nhmenu(wid, how, selected);
++}
++
++/*
++    -- Indicate to the window port that the inventory has been changed.
++    -- Merely calls display_inventory() for window-ports that leave the 
++	window up, otherwise empty.
++*/
++void curses_update_inventory()
++{
++}
++
++/*
++mark_synch()    -- Don't go beyond this point in I/O on any channel until
++                   all channels are caught up to here.  Can be an empty call
++                   for the moment
++*/
++void curses_mark_synch()
++{
++}
++
++/*
++wait_synch()    -- Wait until all pending output is complete (*flush*() for
++                   streams goes here).
++                -- May also deal with exposure events etc. so that the
++                   display is OK when return from wait_synch().
++*/
++void curses_wait_synch()
++{
++}
++
++/*
++cliparound(x, y)-- Make sure that the user is more-or-less centered on the
++                   screen if the playing area is larger than the screen.
++                -- This function is only defined if CLIPPING is defined.
++*/
++void curses_cliparound(int x, int y)
++{
++}
++
++/*
++print_glyph(window, x, y, glyph)
++                -- Print the glyph at (x,y) on the given window.  Glyphs are
++                   integers at the interface, mapped to whatever the window-
++                   port wants (symbol, font, color, attributes, ...there's
++                   a 1-1 map between glyphs and distinct things on the map).
++*/
++void curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph)
++{
++    int ch, color, special;
++    int attr = -1;
++
++    /* map glyph to character and color */
++    mapglyph(glyph, &ch, &color, &special, x, y);
++    if ((special & MG_PET) && iflags.hilite_pet)
++    {
++        attr = ATR_ULINE;
++    }
++    if ((special & MG_DETECT) && iflags.use_inverse)
++	{
++	    attr = ATR_INVERSE;
++	}
++	if (iflags.cursesgraphics)
++	{
++	    ch = curses_convert_glyph(ch, glyph);
++	}
++    curses_putch(wid, x, y, ch, color, attr);
++}
++
++/*
++raw_print(str)  -- Print directly to a screen, or otherwise guarantee that
++                   the user sees str.  raw_print() appends a newline to str.
++                   It need not recognize ASCII control characters.  This is
++                   used during startup (before windowing system initialization
++                   -- maybe this means only error startup messages are raw),
++                   for error messages, and maybe other "msg" uses.  E.g.
++                   updating status for micros (i.e, "saving").
++*/
++void curses_raw_print(const char *str)
++{
++    puts(str);
++}
++
++/*
++raw_print_bold(str)
++            -- Like raw_print(), but prints in bold/standout (if possible).
++*/
++void curses_raw_print_bold(const char *str)
++{
++    curses_raw_print(str);
++}
++
++/*
++int nhgetch()   -- Returns a single character input from the user.
++                -- In the tty window-port, nhgetch() assumes that tgetch()
++                   will be the routine the OS provides to read a character.
++                   Returned character _must_ be non-zero.
++*/
++int curses_nhgetch()
++{    
++    int ch;
++    
++    curses_prehousekeeping();
++    ch = curses_read_char();
++    curses_posthousekeeping();
++    
++    return ch;
++}
++
++/*
++int nh_poskey(int *x, int *y, int *mod)
++                -- Returns a single character input from the user or a
++                   a positioning event (perhaps from a mouse).  If the
++                   return value is non-zero, a character was typed, else,
++                   a position in the MAP window is returned in x, y and mod.
++                   mod may be one of
++
++                        CLICK_1         -- mouse click type 1 
++                        CLICK_2         -- mouse click type 2 
++
++                   The different click types can map to whatever the
++                   hardware supports.  If no mouse is supported, this
++                   routine always returns a non-zero character.
++*/
++int curses_nh_poskey(int *x, int *y, int *mod)
++{
++    return curses_nhgetch();
++}
++
++/*
++nhbell()        -- Beep at user.  [This will exist at least until sounds are
++                   redone, since sounds aren't attributable to windows anyway.]
++*/
++void curses_nhbell()
++{
++    beep();
++}
++
++/*
++doprev_message()
++                -- Display previous messages.  Used by the ^P command.
++                -- On the tty-port this scrolls WIN_MESSAGE back one line.
++*/
++int curses_doprev_message()
++{
++    curses_prev_mesg();
++}
++
++/*
++char yn_function(const char *ques, const char *choices, char default)
++                -- Print a prompt made up of ques, choices and default.
++                   Read a single character response that is contained in
++                   choices or default.  If choices is NULL, all possible
++                   inputs are accepted and returned.  This overrides
++                   everything else.  The choices are expected to be in
++                   lower case.  Entering ESC always maps to 'q', or 'n',
++                   in that order, if present in choices, otherwise it maps
++                   to default.  Entering any other quit character (SPACE,
++                   RETURN, NEWLINE) maps to default.
++                -- If the choices string contains ESC, then anything after
++                   it is an acceptable response, but the ESC and whatever
++                   follows is not included in the prompt.
++                -- If the choices string contains a '#' then accept a count.
++                   Place this value in the global "yn_number" and return '#'.
++                -- This uses the top line in the tty window-port, other
++                   ports might use a popup.
++*/
++char curses_yn_function(const char *question, const char *choices, CHAR_P def)
++{
++    curses_character_input_dialog(question, choices, def);
++}
++
++/*
++getlin(const char *ques, char *input)
++	    -- Prints ques as a prompt and reads a single line of text,
++	       up to a newline.  The string entered is returned without the
++	       newline.  ESC is used to cancel, in which case the string
++	       "\033\000" is returned.
++	    -- getlin() must call flush_screen(1) before doing anything.
++	    -- This uses the top line in the tty window-port, other
++	       ports might use a popup.
++*/
++void curses_getlin(const char *question, char *input)
++{
++    curses_line_input_dialog(question, input, BUFSZ);
++}
++
++/*
++int get_ext_cmd(void)
++	    -- Get an extended command in a window-port specific way.
++	       An index into extcmdlist[] is returned on a successful
++	       selection, -1 otherwise.
++*/
++int curses_get_ext_cmd()
++{
++    return curses_ext_cmd();
++}
++
++
++/*
++number_pad(state)
++	    -- Initialize the number pad to the given state.
++*/
++void curses_number_pad(int state)
++{
++}
++
++/*
++delay_output()  -- Causes a visible delay of 50ms in the output.
++	       Conceptually, this is similar to wait_synch() followed
++	       by a nap(50ms), but allows asynchronous operation.
++*/
++void curses_delay_output()
++{
++//    curses_refresh_nethack_windows();
++//    usleep(5000);
++}
++
++/*
++start_screen()  -- Only used on Unix tty ports, but must be declared for
++	       completeness.  Sets up the tty to work in full-screen
++	       graphics mode.  Look at win/tty/termcap.c for an
++	       example.  If your window-port does not need this function
++	       just declare an empty function.
++*/
++void curses_start_screen()
++{
++}
++
++/*
++end_screen()    -- Only used on Unix tty ports, but must be declared for
++	       completeness.  The complement of start_screen().
++*/
++void curses_end_screen()
++{
++}
++
++/*
++outrip(winid, int)
++	    -- The tombstone code.  If you want the traditional code use
++	       genl_outrip for the value and check the #if in rip.c.
++*/
++void curses_outrip(winid wid, int how)
++{
++}
++
++/*
++preference_update(preference)
++		-- The player has just changed one of the wincap preference
++		   settings, and the NetHack core is notifying your window
++		   port of that change.  If your window-port is capable of
++		   dynamically adjusting to the change then it should do so.
++		   Your window-port will only be notified of a particular
++		   change if it indicated that it wants to be by setting the 
++		   corresponding bit in the wincap mask.
++*/
++void curses_preference_update(const char *pref)
++{
++    if ((strcmp(pref, "align_status") == 0) ||
++     (strcmp(pref, "align_message") == 0))
++    {
++        curses_create_main_windows();
++        curses_last_messages();
++        doredraw();
++    }
++}
+diff -burN nethack-3.4.3/win/curses/cursmesg.c nethack/win/curses/cursmesg.c
+--- nethack-3.4.3/win/curses/cursmesg.c	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursmesg.c	2009-03-11 15:08:53.000000000 -0400
+@@ -0,0 +1,365 @@
++#include "curses.h"
++#include "hack.h"
++#include "wincurs.h"
++#include "cursmesg.h"
++
++/* Message window routines for curses interface */
++
++static int turn_lines = 1;
++static int mx = 0;
++static int my = 0;  /* message window text location */
++static nhprev_mesg *first_mesg = NULL;
++static nhprev_mesg *last_mesg = NULL;
++static int max_messages;
++static int num_messages = 0;
++
++
++
++/* Write a string to the message window.  Attributes set by calling function. */
++
++void curses_message_win_puts(const char *message, boolean recursed)
++{
++    int height, width, linespace, count;
++    char *tmpstr;
++    WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
++    boolean border = curses_window_has_border(MESSAGE_WIN);
++    int message_length = strlen(message);
++    int border_space = 0;
++    
++    if (!recursed)
++    {
++        strcpy(toplines, message);
++        mesg_add_line((char *) message);
++    }
++    
++    curses_get_window_size(MESSAGE_WIN, &height, &width);
++    if (border)
++    {
++        border_space = 1;
++        if (mx < 1)
++        {
++            mx = 1;
++        }
++        if (my < 1)
++        {
++            my = 1;
++        }
++    }
++    
++    linespace = ((width + border_space) - 3) - mx;
++    
++    if (linespace < message_length)
++    {
++        if (my >= (height - 1 + border_space)) /* bottom of message win */
++        {
++            if (turn_lines == height)
++            {
++                curses_more();
++            }
++            else
++            {
++                scroll_window(MESSAGE_WIN);
++                turn_lines++;
++            }
++        }
++        else
++        {
++            if (mx != border_space)
++            {
++                my++;
++                mx = border_space;
++            }
++        }
++    }
++
++    if (height > 1)
++    {
++        curses_toggle_color_attr(win, NONE, ATR_BOLD, ON);
++    }
++    
++    if ((mx == border_space) && ((message_length + 2) > width))
++    {
++        tmpstr = curses_break_str(message, (width - 2), 1);
++        mvwprintw(win, my, mx, tmpstr);
++        mx += strlen(tmpstr);
++        free(tmpstr);
++        if (height > 1)
++        {
++            curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF);
++        }
++        wrefresh(win);
++        curses_message_win_puts(curses_str_remainder(message, (width - 2), 1),
++         TRUE);
++    }
++    else
++    {
++        mvwprintw(win, my, mx, message);
++        curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF);
++    }
++    wrefresh(win);
++    mx += message_length + 1;
++}
++
++
++void curses_more()
++{
++    int height, width;
++    WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
++    
++    curses_get_window_size(MESSAGE_WIN, &height, &width);
++    curses_toggle_color_attr(win, MORECOLOR, NONE, ON);
++    mvwprintw(win, my, mx - 1, ">>");
++    curses_toggle_color_attr(win, MORECOLOR, NONE, OFF);
++    wrefresh(win);
++    wgetch(win);
++    if (height == 1)
++    {
++        curses_clear_unhighlight_message_window();
++    }
++    else
++    {
++        mvwprintw(win, my, mx - 1, "  ");
++        scroll_window(MESSAGE_WIN);
++        turn_lines = 1;
++    }
++}
++
++
++/* Clear the message window if one line; otherwise unhighlight old messages */
++
++void curses_clear_unhighlight_message_window()
++{
++    int mh, mw, count;
++    boolean border = curses_window_has_border(MESSAGE_WIN);
++    WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
++
++    turn_lines = 1;
++    
++    curses_get_window_size(MESSAGE_WIN, &mh, &mw); 
++    
++    mx = 0;
++    
++    if (border)
++    {
++        mx++;
++    }
++       
++    if (mh == 1)
++    {
++        curses_clear_nhwin(MESSAGE_WIN);
++    }
++    else
++    {
++        mx += mw;    /* Force new line on new turn */
++        
++        if (border)
++        {
++
++            for (count = 0; count < mh; count++)
++            {
++                mvwchgat(win, count+1, 1, mw, COLOR_PAIR(8), A_NORMAL, NULL);
++            }
++        }
++        else
++        {
++            for (count = 0; count < mh; count++)
++            {
++                mvwchgat(win, count, 0, mw, COLOR_PAIR(8), A_NORMAL, NULL);
++            }
++        }
++
++        wrefresh(win);
++    }
++}
++
++
++/* Reset message window cursor to starting position, and display most
++recent messages. */
++
++void curses_last_messages()
++{
++    boolean border = curses_window_has_border(MESSAGE_WIN);
++
++    if (border)
++    {
++        mx = 1;
++        my = 1;
++    }
++    else
++    {
++        mx = 0;
++        my = 0;
++    }
++    
++    pline(toplines);
++}
++
++
++/* Initialize list for message history */
++
++void curses_init_mesg_history()
++{
++    max_messages = iflags.msg_history;
++    
++    if (max_messages < 1)
++    {
++        max_messages = 1;
++    }
++
++    if (max_messages > MESG_HISTORY_MAX)
++    {
++        max_messages = MESG_HISTORY_MAX;
++    }
++}
++
++
++/* Display previous message window messages in reverse chron order */
++
++void curses_prev_mesg()
++{
++    int count;
++    winid wid;
++    long turn = 0;
++    anything *identifier;
++    nhprev_mesg *mesg;
++    menu_item *selected = NULL;
++
++    wid = curses_get_wid(NHW_MENU);
++    curses_create_nhmenu(wid);
++    identifier = malloc(sizeof(anything));
++    identifier->a_void = NULL;
++    
++    for (count = 0; count < num_messages; count++)
++    {
++        mesg = get_msg_line(TRUE, count);
++        if ((turn != mesg->turn) && (count != 0))
++        {
++            curses_add_menu(wid, NO_GLYPH, identifier, 0, 0, A_NONE,
++             "---", FALSE);
++        }
++        curses_add_menu(wid, NO_GLYPH, identifier, 0, 0, A_NONE,
++         mesg->str, FALSE);
++        turn = mesg->turn;
++    }
++    
++    curses_end_menu(wid, "");
++    curses_select_menu(wid, PICK_NONE, &selected);
++}
++
++
++/* Scroll lines upward in given window, or clear window if only one line. */
++
++static void scroll_window(winid wid)
++{
++    int wh, ww, s_top, s_bottom;
++    boolean border = curses_window_has_border(wid);
++    WINDOW *win = curses_get_nhwin(wid);
++    
++    curses_get_window_size(wid, &wh, &ww);
++    if (wh == 1)
++    {
++        curses_clear_nhwin(wid);
++        return;
++    }
++    if (border)
++    {
++        s_top = 1;
++        s_bottom = wh;
++    }
++    else
++    {
++        s_top = 0;
++        s_bottom = wh - 1;
++    }
++    scrollok(win, TRUE);
++    wsetscrreg(win, s_top, s_bottom);
++    scroll(win);
++    scrollok(win, FALSE);
++    if (wid == MESSAGE_WIN)
++    {
++        if (border)
++            mx = 1;
++        else
++            mx = 0;
++    }
++    if (border)
++    {
++        box(win, 0, 0);
++    }
++    wrefresh(win);
++}
++
++
++/* Add given line to message history */
++
++static void mesg_add_line(char *mline)
++{
++    nhprev_mesg *tmp_mesg = NULL;
++    nhprev_mesg *current_mesg = malloc(sizeof(nhprev_mesg));
++
++    current_mesg->str = curses_copy_of(mline);
++    current_mesg->turn = moves;
++    current_mesg->next_mesg = NULL;
++
++    if (num_messages == 0)
++    {
++        first_mesg = current_mesg;
++    }
++    
++    if (last_mesg != NULL)
++    {
++        last_mesg->next_mesg = current_mesg;
++    }
++    current_mesg->prev_mesg = last_mesg;
++    last_mesg = current_mesg;
++
++
++    if (num_messages < max_messages)
++    {
++        num_messages++;
++    }
++    else
++    {
++        tmp_mesg = first_mesg->next_mesg;
++        free(first_mesg);
++        first_mesg = tmp_mesg;
++    }
++}
++
++
++/* Returns specified line from message history, or NULL if out of bounds */
++
++static nhprev_mesg *get_msg_line(boolean reverse, int mindex)
++{
++    int count;
++    char *line;
++    nhprev_mesg *current_mesg;
++
++    if (reverse)
++    {
++        current_mesg = last_mesg;
++        for (count = 0; count < mindex; count++)
++        {
++            if (current_mesg == NULL)
++            {
++                return NULL;
++            }
++            current_mesg = current_mesg->prev_mesg;
++        }
++        return current_mesg;
++    }
++    else
++    {
++        current_mesg = first_mesg;
++        for (count = 0; count < mindex; count++)
++        {
++            if (current_mesg == NULL)
++            {
++                return NULL;
++            }
++            current_mesg = current_mesg->next_mesg;
++        }
++        return current_mesg;
++    }
++}
++
+diff -burN nethack-3.4.3/win/curses/cursmesg.h nethack/win/curses/cursmesg.h
+--- nethack-3.4.3/win/curses/cursmesg.h	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursmesg.h	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,37 @@
++#ifndef CURSMESG_H
++#define CURSMESG_H
++
++
++/* Global declarations */
++
++void curses_message_win_puts(const char *message, boolean recursed);
++
++void curses_more(void);
++
++void curses_clear_unhighlight_message_window(void);
++
++void curses_last_messages(void);
++
++void curses_init_mesg_history(void);
++
++void curses_prev_mesg(void);
++
++
++/* Private declatations */
++
++typedef struct nhpm
++{
++    char *str;  /* Message text */
++    long turn;  /* Turn number for message */
++    struct nhpm *prev_mesg;    /* Pointer to previous message */
++    struct nhpm *next_mesg;    /* Pointer to next message */
++} nhprev_mesg;
++
++static void scroll_window(winid wid);
++
++static void mesg_add_line(char *mline);
++
++static nhprev_mesg *get_msg_line(boolean reverse, int mindex);
++
++
++#endif  /* CURSMESG_H */
+diff -burN nethack-3.4.3/win/curses/cursmisc.c nethack/win/curses/cursmisc.c
+--- nethack-3.4.3/win/curses/cursmisc.c	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursmisc.c	2009-03-11 15:08:53.000000000 -0400
+@@ -0,0 +1,647 @@
++#include "curses.h"
++#include "hack.h"
++#include "wincurs.h"
++#include "cursmisc.h"
++#include "func_tab.h"
++#include "dlb.h"
++
++/* Misc. curses interface functions */
++
++static int curs_x = -1;
++static int curs_y = -1;
++static winid curs_win = 0;
++
++
++/* Read a character of input from the user */
++
++int curses_read_char()
++{
++    int ch;
++
++    ch = getch();
++    if (!ch)
++    {
++        ch = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
++    }
++    
++    if ((ch >= 0x197) && (ch <= 0x1ba)) /* Alt/Meta key handling */
++    {
++        ch = (ch - 0x140) | 0x80;
++    }
++
++#ifdef KEY_RESIZE
++    /* Handle resize events via get_nh_event, not this code */
++    if (ch == KEY_RESIZE)
++    {
++        ch = '\033'; /* NetHack doesn't know what to do with KEY_RESIZE */
++    }
++#endif
++
++    /* Handle arrow keys */
++    
++    switch (ch)
++    {
++        case KEY_LEFT:
++        {
++            if (iflags.num_pad)
++            {
++                ch = '4';
++            }
++            else
++            {
++                ch = 'h';
++            }
++            break;
++        }
++        case KEY_RIGHT:
++        {
++            if (iflags.num_pad)
++            {
++                ch = '6';
++            }
++            else
++            {
++                ch = 'l';
++            }
++            break;
++        }
++        case KEY_UP:
++        {
++            if (iflags.num_pad)
++            {
++                ch = '8';
++            }
++            else
++            {
++                ch = 'k';
++            }
++            break;
++        }
++        case KEY_DOWN:
++        {
++            if (iflags.num_pad)
++            {
++                ch = '2';
++            }
++            else
++            {
++                ch = 'j';
++            }
++            break;
++        }
++    }
++
++    return ch;
++}
++
++/* Turn on or off the specified color and / or attribute */
++
++void curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff)
++{
++#ifdef TEXTCOLOR
++    int curses_color, curses_attr;
++
++    switch (attr)
++    {
++        case ATR_NONE:
++        {
++            curses_attr = A_NORMAL;
++            break;
++        }
++        case ATR_ULINE:
++        {
++            curses_attr = A_UNDERLINE;
++            break;
++        }
++        case ATR_BOLD:
++        {
++            curses_attr = A_BOLD;
++            break;
++        }
++        case ATR_BLINK:
++        {
++            curses_attr = A_BLINK;
++            break;
++        }
++        case ATR_INVERSE:
++        {
++            curses_attr = A_REVERSE;
++            break;
++        }
++        default:
++        {
++            curses_attr = A_NORMAL;
++        }
++    }
++    if (color == 0) /* make black fg visible */
++#ifdef CURSES_VERSION
++        color = 16;
++#else
++        color = 8;
++#endif
++    curses_color = color + 1;
++    if (curses_color > 8)
++        curses_color -= 8;
++    if (onoff == ON)    /* Turn on color/attributes */
++    {
++        if ((attr != NONE) && iflags.use_color)
++            wattron(win, curses_attr);
++        if ((color != NONE) && iflags.use_color)
++        {
++            if ((color > 7) && iflags.use_color)  /* high-intensity color */
++                wattron(win, A_BOLD);
++            if (iflags.use_color)
++                wattron(win, COLOR_PAIR(curses_color));
++        }
++    }
++    else                /* Turn off color/attributes */
++    {
++        if ((attr != NONE) && iflags.use_color)
++            wattroff(win, curses_attr);
++        if ((color != NONE) && iflags.use_color)
++        {
++            if ((color > 7) && iflags.use_color)  /* high-intensity color */
++                wattroff(win, A_BOLD);
++            if (iflags.use_color)
++                wattroff(win, COLOR_PAIR(curses_color));
++        }
++    }
++#endif
++}
++
++
++/* clean up and quit - taken from tty port */
++
++void curses_bail(const char *mesg)
++{
++    clearlocks();
++    curses_exit_nhwindows(mesg);
++    terminate(EXIT_SUCCESS);
++}
++
++
++/* Return a winid for a new window of the given type */
++
++winid curses_get_wid(int type)
++{
++	winid ret;
++    static winid menu_wid = 20; /* Always even */
++    static winid text_wid = 21; /* Always odd */
++
++	switch (type)
++	{
++		case NHW_MESSAGE:
++		{
++			return MESSAGE_WIN;
++			break;
++		}
++		case NHW_MAP:
++		{
++			return MAP_WIN;
++			break;
++		}
++		case NHW_STATUS:
++		{
++			return STATUS_WIN;
++			break;
++		}
++		case NHW_MENU:
++		{
++			ret = menu_wid;
++			break;
++		}
++		case NHW_TEXT:
++		{
++			ret = text_wid;
++			break;
++		}
++		default:
++		{
++			panic("curses_get_wid: unsupported window type");
++		}
++	}
++
++	while (curses_window_exists(ret))
++	{
++	    ret += 2;
++	    if ((ret + 2) > 10000)    /* Avoid "wid2k" problem */
++	    {
++	        ret -= 9900;
++	    }
++	}
++	
++	if (type == NHW_MENU)
++	{
++	    menu_wid += 2;
++	}
++	else
++	{
++	    text_wid += 2;
++	}
++
++	return ret;
++}
++
++
++/*
++ * Allocate a copy of the given string.  If null, return a string of
++ * zero length.
++ *
++ * This is taken from copy_of() in tty/wintty.c.
++ */
++
++char *curses_copy_of(const char *s)
++{
++    if (!s) s = "";
++    return strcpy((char *) alloc((unsigned) (strlen(s) + 1)), s);
++}
++
++
++/* Determine the number of lines needed for a string for a dialog window
++of the given width */
++
++int curses_num_lines(const char *str, int width)
++{
++    int last_space, count;
++    int curline = 1;
++    char substr[BUFSZ];
++    char tmpstr[BUFSZ];
++    
++    strcpy(substr, str);
++    
++    while (strlen(substr) > width)
++    {
++        last_space = 0;
++        
++        for (count = 0; count <= width; count++)
++        {
++            if (substr[count] == ' ')
++            last_space = count;
++        }
++        if (last_space == 0)    /* No spaces found */
++        {
++            last_space = count - 1;
++        }
++        for (count = (last_space + 1); count < strlen(substr); count++)
++        {
++            tmpstr[count - (last_space + 1)] = substr[count];
++        }
++        tmpstr[count - (last_space + 1)] = '\0';
++        strcpy(substr, tmpstr);
++        curline++;
++    }
++    
++    return curline;
++}
++
++
++/* Break string into smaller lines to fit into a dialog window of the
++given width */
++
++char *curses_break_str(const char *str, int width, int line_num)
++{
++    int last_space, count;
++    char *retstr;
++    int curline = 0;
++    int strsize = strlen(str);
++    char substr[strsize];
++    char curstr[strsize];
++    char tmpstr[strsize];
++    
++    strcpy(substr, str);
++    
++    while (curline < line_num)
++    {
++        if (strlen(substr) == 0 )
++        {
++            break;
++        }
++        curline++;
++        last_space = 0;       
++        for (count = 0; count <= width; count++)
++        {
++            if (substr[count] == ' ')
++            {
++                last_space = count;
++            }
++            else if (substr[count] == '\0')           
++            {
++                last_space = count;
++                break;
++            }
++        }
++        if (last_space == 0)    /* No spaces found */
++        {
++            last_space = count - 1;
++        }
++        for (count = 0; count < last_space; count++)
++        {
++            curstr[count] = substr[count];
++        }
++        curstr[count] = '\0';
++        if (substr[count] == '\0')
++        {
++            break;
++        }
++        for (count = (last_space + 1); count < strlen(substr); count++)
++        {
++            tmpstr[count - (last_space + 1)] = substr[count];
++        }
++        tmpstr[count - (last_space + 1)] = '\0';
++        strcpy(substr, tmpstr);
++    }
++    
++    if (curline < line_num)
++    {
++        return NULL;
++    }
++    
++    retstr = curses_copy_of(curstr);
++    
++    return retstr;
++}
++
++
++/* Return the remaining portion of a string after hacking-off line_num lines */
++
++char *curses_str_remainder(const char *str, int width, int line_num)
++{
++    int last_space, count;
++    char *retstr;
++    int curline = 0;
++    int strsize = strlen(str);
++    char substr[strsize];
++    char curstr[strsize];
++    char tmpstr[strsize];
++    
++    strcpy(substr, str);
++    
++    while (curline < line_num)
++    {
++        if (strlen(substr) == 0 )
++        {
++            break;
++        }
++        curline++;
++        last_space = 0;       
++        for (count = 0; count <= width; count++)
++        {
++            if (substr[count] == ' ')
++            {
++                last_space = count;
++            }
++            else if (substr[count] == '\0')           
++            {
++                last_space = count;
++                break;
++            }
++        }
++        if (last_space == 0)    /* No spaces found */
++        {
++            last_space = count - 1;
++        }
++        for (count = 0; count < last_space; count++)
++        {
++            curstr[count] = substr[count];
++        }
++        curstr[count] = '\0';
++        if (substr[count] == '\0')
++        {
++            break;
++        }
++        for (count = (last_space + 1); count < strlen(substr); count++)
++        {
++            tmpstr[count - (last_space + 1)] = substr[count];
++        }
++        tmpstr[count - (last_space + 1)] = '\0';
++        strcpy(substr, tmpstr);
++    }
++    
++    if (curline < line_num)
++    {
++        return NULL;
++    }
++    
++    retstr = curses_copy_of(substr);
++    
++    return retstr;
++}
++
++
++/* Determine if the given NetHack winid is a menu window */
++
++boolean curses_is_menu(winid wid)
++{
++    if ((wid > 19) && !(wid % 2))   /* Even number */
++    {
++        return TRUE;
++    }
++    else
++    {
++        return FALSE;
++    }
++}
++
++
++/* Determine if the given NetHack winid is a text window */
++
++boolean curses_is_text(winid wid)
++{
++    if ((wid > 19) && (wid % 2))   /* Odd number */
++    {
++        return TRUE;
++    }
++    else
++    {
++        return FALSE;
++    }
++}
++
++
++/* Replace certain characters with portable drawing characters if
++cursesgraphics option is enabled */
++
++int curses_convert_glyph(int ch, int glyph)
++{
++    int symbol;
++    
++    /* Save some processing time by returning if the glyph represents
++    an object that we don't have custom characters for */
++    if (!glyph_is_cmap(glyph))
++    {
++        return ch;
++    }
++    
++    symbol = glyph_to_cmap(glyph);
++    
++    /* If user selected a custom character for this object, don't
++    override this. */
++    if (((glyph_is_cmap(glyph)) && (ch != showsyms[symbol])))
++    {
++        return ch;
++    }
++
++    switch (symbol)
++    {
++        case S_vwall:
++            return ACS_VLINE;
++        case S_hwall:
++            return ACS_HLINE;
++        case S_tlcorn:
++            return ACS_ULCORNER;
++        case S_trcorn:
++            return ACS_URCORNER;
++        case S_blcorn:
++            return ACS_LLCORNER;
++        case S_brcorn:
++            return ACS_LRCORNER;
++        case S_crwall:
++            return ACS_PLUS;
++        case S_tuwall:
++            return ACS_TTEE;
++        case S_tdwall:
++            return ACS_BTEE;
++        case S_tlwall:
++            return ACS_LTEE;
++        case S_trwall:
++            return ACS_RTEE;
++        case S_tree:
++            return ACS_PLMINUS;
++        case S_corr:
++            return ACS_CKBOARD;
++        case S_litcorr:
++            return ACS_CKBOARD;
++    }
++
++	return ch;
++}
++
++
++/* Move text cursor to specified coordinates in the given NetHack window */
++
++void curses_move_cursor(winid wid, int x, int y)
++{
++    WINDOW *win = curses_get_nhwin(curs_win);
++
++    if (wid != MAP_WIN)
++    {
++        return;
++    }
++
++#ifdef PDCURSES
++    /* PDCurses seems to not handle wmove correctly, so we use move and
++    physical screen coordinates instead */
++    curses_get_window_xy(wid, &curs_x, &curs_y);
++    curs_x += x;
++    curs_y += y;
++#else
++    curs_x = x;
++    curs_y = y;
++#endif    
++    curs_win = wid;
++#ifdef PDCURSES
++    move(curs_y, curs_x);
++#else
++    wmove(win, curs_y, curs_x);
++#endif
++}
++
++
++/* Perform actions that should be done every turn before nhgetch() */
++
++void curses_prehousekeeping()
++{
++    WINDOW *win = curses_get_nhwin(curs_win);
++
++    if ((curs_x > -1) && (curs_y > -1))
++    {
++        curs_set(1);
++#ifdef PDCURSES
++        /* PDCurses seems to not handle wmove correctly, so we use move
++        and physical screen coordinates instead */
++        move(curs_y, curs_x);
++#else
++        wmove(win, curs_y, curs_x);
++#endif
++        curses_refresh_nhwin(curs_win);
++    }
++}
++
++
++/* Perform actions that should be done every turn after nhgetch() */
++
++void curses_posthousekeeping()
++{
++    curs_set(0);
++    curses_decrement_highlight();
++    curses_clear_unhighlight_message_window();
++}
++
++
++void curses_view_file(const char *filename, boolean must_exist)
++{
++    winid wid;
++    anything *identifier;
++    char buf[BUFSZ];
++    menu_item *selected = NULL;
++    dlb *fp = dlb_fopen(filename, "r");
++    
++    if ((fp == NULL) && (must_exist))
++    {
++        pline("Cannot open %s for reading!", filename);
++    }
++
++    if (fp == NULL)
++    {
++        return;
++    }
++    
++    wid = curses_get_wid(NHW_MENU);
++    curses_create_nhmenu(wid);
++    identifier = malloc(sizeof(anything));
++    identifier->a_void = NULL;
++    
++    while (dlb_fgets(buf, BUFSZ, fp) != NULL)
++    {
++        curses_add_menu(wid, NO_GLYPH, identifier, 0, 0, A_NONE, buf,
++         FALSE);
++    }
++    
++    dlb_fclose(fp);
++    curses_end_menu(wid, "");
++    curses_select_menu(wid, PICK_NONE, &selected);
++}
++
++
++char *curses_rtrim(char *str)
++{
++    char *s;
++
++    for(s = str; *s != '\0'; ++s);
++    for(--s;isspace(*s) && s > str; --s);
++    if(s == str) *s = '\0';
++    else *(++s) = '\0';
++}
++
++/* Use nethack wall symbols for drawing unless cursesgraphics is
++defined, in which case we use the standard curses ones.  Not sure if
++this is desirable behavior since one may prefer regular lines for
++borders but traditional symbols to draw rooms.  Commenting it out for
++now. */
++
++/*
++ * void curses_border(WINDOW *win)
++ * {
++ *     if (iflags.cursesgraphics)
++ *     {
++ *         box(win, 0, 0);
++ *     }
++ *     else
++ *     {
++ *         wborder(win, showsyms[S_vwall], showsyms[S_vwall],
++ *          showsyms[S_hwall], showsyms[S_hwall], showsyms[S_tlcorn],
++ *          showsyms[S_trcorn], showsyms[S_blcorn], showsyms[S_brcorn]);
++ *     }
++ * }
++ */
++
+diff -burN nethack-3.4.3/win/curses/cursmisc.h nethack/win/curses/cursmisc.h
+--- nethack-3.4.3/win/curses/cursmisc.h	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursmisc.h	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,38 @@
++#ifndef CURSMISC_H
++#define CURSMISC_H
++
++/* Global declarations */
++
++int curses_read_char(void);
++
++void curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff);
++
++void curses_bail(const char *mesg);
++
++winid curses_get_wid(int type);
++
++char *curses_copy_of(const char *s);
++
++int curses_num_lines(const char *str, int width);
++
++char *curses_break_str(const char *str, int width, int line_num);
++
++char *curses_str_remainder(const char *str, int width, int line_num);
++
++boolean curses_is_menu(winid wid);
++
++boolean curses_is_text(winid wid);
++
++int curses_convert_glyph(int ch, int glyph);
++
++void curses_move_cursor(winid wid, int x, int y);
++
++void curses_prehousekeeping(void);
++
++void curses_posthousekeeping(void);
++
++void curses_view_file(const char *filename, boolean must_exist);
++
++char *curses_rtrim(char *str);
++
++#endif  /* CURSMISC_H */
+diff -burN nethack-3.4.3/win/curses/cursstat.c nethack/win/curses/cursstat.c
+--- nethack-3.4.3/win/curses/cursstat.c	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursstat.c	2009-03-11 15:08:53.000000000 -0400
+@@ -0,0 +1,2145 @@
++#include "curses.h"
++#include "hack.h"
++#include "wincurs.h"
++#include "cursstat.h"
++
++/* Status window functions for curses interface */
++
++static nhstat prevname;
++static nhstat prevdepth;
++static nhstat prevstr;
++static nhstat prevint;
++static nhstat prevwis;
++static nhstat prevdex;
++static nhstat prevcon;
++static nhstat prevcha;
++static nhstat prevalign;  
++static nhstat prevau;
++static nhstat prevhp;
++static nhstat prevmhp;
++static nhstat prevlevel;
++static nhstat prevpow;
++static nhstat prevmpow;
++static nhstat prevac;
++static nhstat prevexp;
++static nhstat prevtime;
++static nhstat prevscore;
++static nhstat prevhunger;
++static nhstat prevconf;
++static nhstat prevblind;
++static nhstat prevstun;
++static nhstat prevhallu;
++static nhstat prevsick;
++static nhstat prevslime;
++static nhstat prevencumb;
++
++extern const char *hu_stat[]; /* from eat.c */
++extern const char *enc_stat[]; /* from botl.c */
++
++/* Update the status win - this is called when NetHack would normally
++write to the status window, so we know somwthing has changed.  We
++override the write and update what needs to be updated ourselves. */
++
++void curses_update_stats()
++{
++    char buf[BUFSZ];
++    int count, enc, orient, sx_start;
++    WINDOW *win = curses_get_nhwin(STATUS_WIN);
++    static boolean first = TRUE;
++    boolean horiz;
++    int sx = 0;
++    int sy = 0;
++    boolean border = curses_window_has_border(STATUS_WIN);
++    
++    if (border)
++    {
++        sx++;
++        sy++;
++    }
++    
++    sx_start = sx;
++        
++    if (first)
++    {
++        init_stats();
++        first = FALSE;
++    }
++    
++    orient = curses_get_window_orientation(STATUS_WIN);
++
++    if ((orient == ALIGN_RIGHT) || (orient == ALIGN_LEFT))
++    {
++        horiz = FALSE;
++    }
++    else
++    {
++        horiz = TRUE;
++    }
++
++    curses_clear_nhwin(STATUS_WIN);
++    
++    /* Line 1 */
++    
++    /* Player name and title */
++    strcpy(buf, plname);
++    if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a';
++    strcat(buf, " the ");
++    if (u.mtimedone) {
++        char mname[BUFSZ];
++        int k = 0;
++
++        strcpy(mname, mons[u.umonnum].mname);
++        while(mname[k] != 0) {
++            if ((k == 0 || (k > 0 && mname[k-1] == ' '))
++             && 'a' <= mname[k] && mname[k] <= 'z')
++            {
++                mname[k] += 'A' - 'a';
++            }
++            k++;
++        }
++        strcat(buf, mname);
++    } else {
++        strcat(buf, rank_of(u.ulevel, pl_character[0], flags.female));
++    }
++    
++    if (strcmp(buf, prevname.txt) != 0) /* Title changed */
++    {
++        prevname.highlight_turns = 5;
++        prevname.highlight_color = HIGHLIGHT_COLOR;
++        free(prevname.txt);
++        prevname.txt = curses_copy_of(buf);
++    }
++    
++    if (prevname.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevname.label);
++        sx += strlen(prevname.label);
++    }
++    
++    if (prevname.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevname.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevname.txt);
++        curses_toggle_color_attr(win, prevname.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevname.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevname.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++    
++    /* Strength */
++    if (ACURR(A_STR) != prevstr.value)  /* Strength changed */
++    {
++        
++        if (ACURR(A_STR) > prevstr.value)
++        {
++            prevstr.highlight_color = STAT_UP_COLOR;
++        }
++        else
++        {
++            prevstr.highlight_color = STAT_DOWN_COLOR;
++        }
++        prevstr.value = ACURR(A_STR);
++        if (ACURR(A_STR) > 118)
++        {
++            sprintf(buf, "%d", ACURR(A_STR) - 100);
++        }
++        else if (ACURR(A_STR)==118)
++        {
++            sprintf(buf, "18/**");
++        }
++        else if(ACURR(A_STR) > 18)
++        {
++            sprintf(buf, "18/%02d", ACURR(A_STR) - 18);
++        }
++        else
++        {
++            sprintf(buf, "%d", ACURR(A_STR));
++        }
++        free(prevstr.txt);
++        prevstr.txt = curses_copy_of(buf);
++        prevstr.highlight_turns = 5;
++    }
++
++    if (prevstr.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevstr.label);
++        sx += strlen(prevstr.label);
++    }
++    
++    if (prevstr.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevstr.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevstr.txt);
++        curses_toggle_color_attr(win, prevstr.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevstr.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevstr.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Intelligence */
++    if (ACURR(A_INT) != prevint.value)  /* Intelligence changed */
++    {
++        
++        if (ACURR(A_INT) > prevint.value)
++        {
++            prevint.highlight_color = STAT_UP_COLOR;
++        }
++        else
++        {
++            prevint.highlight_color = STAT_DOWN_COLOR;
++        }
++        prevint.value = ACURR(A_INT);
++        sprintf(buf, "%d", ACURR(A_INT)); 
++        free(prevint.txt);
++        prevint.txt = curses_copy_of(buf);
++        prevint.highlight_turns = 5;
++    }
++
++    if (prevint.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevint.label);
++        sx += strlen(prevint.label);
++    }
++    
++    if (prevint.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevint.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevint.txt);
++        curses_toggle_color_attr(win, prevint.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevint.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevint.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Wisdom */
++    if (ACURR(A_WIS) != prevwis.value)  /* Wisdom changed */
++    {
++        
++        if (ACURR(A_WIS) > prevwis.value)
++        {
++            prevwis.highlight_color = STAT_UP_COLOR;
++        }
++        else
++        {
++            prevwis.highlight_color = STAT_DOWN_COLOR;
++        }
++        prevwis.value = ACURR(A_WIS);
++        sprintf(buf, "%d", ACURR(A_WIS)); 
++        free(prevwis.txt);
++        prevwis.txt = curses_copy_of(buf);
++        prevwis.highlight_turns = 5;
++    }
++
++    if (prevwis.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevwis.label);
++        sx += strlen(prevwis.label);
++    }
++    
++    if (prevwis.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevwis.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevwis.txt);
++        curses_toggle_color_attr(win, prevwis.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevwis.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevwis.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Dexterity */
++    if (ACURR(A_DEX) != prevdex.value)  /* Dexterity changed */
++    {
++        
++        if (ACURR(A_DEX) > prevdex.value)
++        {
++            prevdex.highlight_color = STAT_UP_COLOR;
++        }
++        else
++        {
++            prevdex.highlight_color = STAT_DOWN_COLOR;
++        }
++        prevdex.value = ACURR(A_DEX);
++        sprintf(buf, "%d", ACURR(A_DEX));
++        free(prevdex.txt);
++        prevdex.txt = curses_copy_of(buf);
++        prevdex.highlight_turns = 5;
++    }
++
++    if (prevdex.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevdex.label);
++        sx += strlen(prevdex.label);
++    }
++    
++    if (prevdex.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevdex.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevdex.txt);
++        curses_toggle_color_attr(win, prevdex.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevdex.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevdex.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Constitution */
++    if (ACURR(A_CON) != prevcon.value)  /* Constitution changed */
++    {
++        
++        if (ACURR(A_CON) > prevcon.value)
++        {
++            prevcon.highlight_color = STAT_UP_COLOR;
++        }
++        else
++        {
++            prevcon.highlight_color = STAT_DOWN_COLOR;
++        }
++        prevcon.value = ACURR(A_CON);
++        sprintf(buf, "%d", ACURR(A_CON));
++        free(prevcon.txt);
++        prevcon.txt = curses_copy_of(buf);
++        prevcon.highlight_turns = 5;
++    }
++
++    if (prevcon.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevcon.label);
++        sx += strlen(prevcon.label);
++    }
++    
++    if (prevcon.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevcon.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevcon.txt);
++        curses_toggle_color_attr(win, prevcon.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevcon.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevcon.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Charisma */
++    if (ACURR(A_CHA) != prevcha.value)  /* Charisma changed */
++    {
++        if (ACURR(A_CHA) > prevcha.value)
++        {
++            prevcha.highlight_color = STAT_UP_COLOR;
++        }
++        else
++        {
++            prevcha.highlight_color = STAT_DOWN_COLOR;
++        }
++        prevcha.value = ACURR(A_CHA);
++        sprintf(buf, "%d", ACURR(A_CHA));
++        free(prevcha.txt);
++        prevcha.txt = curses_copy_of(buf);
++        prevcha.highlight_turns = 5;
++    }
++
++    if (prevcha.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevcha.label);
++        sx += strlen(prevcha.label);
++    }
++    
++    if (prevcha.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevcha.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevcha.txt);
++        curses_toggle_color_attr(win, prevcha.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevcha.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevcha.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++    
++    /* Alignment */
++    if (prevalign.alignment != u.ualign.type)   /* Alignment changed */
++    {
++        prevalign.highlight_color = HIGHLIGHT_COLOR;
++        prevalign.highlight_turns = 10; /* This is a major change! */
++        prevalign.alignment = u.ualign.type;
++        free(prevalign.txt);
++        switch (u.ualign.type)
++        {
++            case A_LAWFUL:
++            {
++                prevalign.txt = curses_copy_of("Lawful");
++                break;
++            }
++            case A_NEUTRAL:
++            {
++                prevalign.txt = curses_copy_of("Neutral");
++                break;
++            }
++            case A_CHAOTIC:
++            {
++                prevalign.txt = curses_copy_of("Chaotic");
++                break;
++            }
++        }
++    }
++
++    if (prevalign.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevalign.label);
++        sx += strlen(prevalign.label);
++    }
++    
++    if (prevalign.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevalign.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevalign.txt);
++        curses_toggle_color_attr(win, prevalign.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevalign.txt);
++    }
++    
++    /* Line 2 */
++    
++    sx = sx_start;
++    sy++;
++    
++    /* Dungeon Level */
++    if (depth(&u.uz) != prevdepth.value)    /* Dungeon level changed */
++    {
++        prevdepth.highlight_color = HIGHLIGHT_COLOR;
++        prevdepth.highlight_turns = 5;
++        prevdepth.value = depth(&u.uz);
++        free(prevdepth.txt);
++        if (In_endgame(&u.uz))
++        {
++            strcpy(buf, (Is_astralevel(&u.uz) ? "Astral Plane":"End Game"));
++        }
++        else
++        {
++            sprintf(buf, "%d", depth(&u.uz));
++        }
++        prevdepth.txt = curses_copy_of(buf);
++    }
++    
++    if (prevdepth.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevdepth.label);
++        sx += strlen(prevdepth.label);
++    }
++    
++    if (prevdepth.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevdepth.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevdepth.txt);
++        curses_toggle_color_attr(win, prevdepth.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevdepth.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevdepth.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++    
++    /* Gold */
++#ifndef GOLDOBJ
++    if (prevau.value != u.ugold)    /* Gold changed */
++    {
++        if (u.ugold > prevau.value)
++        {
++#else
++    if (prevau.value != money_cnt(invent))  /* Gold changed */
++    {
++        if (money_cnt(invent) > prevau.value)
++        {
++#endif
++            prevau.highlight_color = HI_GOLD;
++        }
++        else
++        {
++            prevau.highlight_color = STAT_DOWN_COLOR;
++        }
++#ifndef GOLDOBJ
++        prevau.value = u.ugold;
++        sprintf(buf,"%ld", u.ugold);
++#else
++        prevau.value = money_cnt(invent);
++        sprintf(buf,"%ld", money_cnt(invent));
++#endif
++        free(prevau.txt);
++        prevau.txt = curses_copy_of(buf);
++        prevau.highlight_turns = 5;
++    }
++    
++    if (prevau.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevau.label);
++        sx += strlen(prevau.label);
++    }
++    
++    if (prevau.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevau.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevau.txt);
++        curses_toggle_color_attr(win, prevau.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevau.txt);
++    }
++
++    if (horiz)
++    {
++        sx += strlen(prevau.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++    
++    /* Hit Points */
++    if (u.mtimedone)    /* Currently polymorphed - show monster HP */
++    {
++	    if (u.mh != prevhp.value)
++	    {
++	        if (u.mh > prevhp.value)
++	        {
++	            prevhp.highlight_color = STAT_UP_COLOR;
++	        }
++	        else
++	        {
++	            prevhp.highlight_color = STAT_DOWN_COLOR;
++	        }
++            prevhp.highlight_turns = 3;
++            prevhp.value = u.mh;
++            sprintf(buf, "%d", u.mh);
++            free(prevhp.txt);
++            prevhp.txt = curses_copy_of(buf);
++	    }
++	}
++	else if (u.uhp != prevhp.value)  /* Not polymorphed */
++	{
++	    if (u.uhp > prevhp.value)
++	    {
++	        prevhp.highlight_color = STAT_UP_COLOR;
++	    }
++	    else
++	    {
++            prevhp.highlight_color = STAT_DOWN_COLOR;
++	    }
++        prevhp.value = u.uhp;
++        sprintf(buf, "%d", u.uhp);
++        free(prevhp.txt);
++        prevhp.txt = curses_copy_of(buf);
++        prevhp.highlight_turns = 3;
++	}
++
++    if (prevhp.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevhp.label);
++        sx += strlen(prevhp.label);
++    }
++
++    if (prevhp.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevhp.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevhp.txt);
++        curses_toggle_color_attr(win, prevhp.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevhp.txt);
++    }
++    
++    sx += strlen(prevhp.txt);
++
++    /* Max Hit Points */
++    if (u.mtimedone)    /* Currently polymorphed - show monster HP */
++    {
++	    if (u.mhmax != prevmhp.value)
++	    {
++	        if (u.mhmax > prevmhp.value)
++	        {
++	            prevmhp.highlight_color = STAT_UP_COLOR;
++	        }
++	        else
++	        {
++	            prevmhp.highlight_color = STAT_DOWN_COLOR;
++	        }
++            prevmhp.value = u.mhmax;
++            sprintf(buf, "%d", u.mhmax);
++            free(prevmhp.txt);
++            prevmhp.txt = curses_copy_of(buf);
++            prevmhp.highlight_turns = 3;
++	    }
++	}
++	else if (u.uhpmax != prevmhp.value)  /* Not polymorphed */
++	{
++	    if (u.uhpmax > prevmhp.value)
++	    {
++	        prevmhp.highlight_color = STAT_UP_COLOR;
++	    }
++	    else
++	    {
++            prevmhp.highlight_color = STAT_DOWN_COLOR;
++	    }
++        prevmhp.value = u.uhpmax;
++        sprintf(buf, "%d", u.uhpmax);
++        free(prevmhp.txt);
++        prevmhp.txt = curses_copy_of(buf);
++        prevmhp.highlight_turns = 3;
++	}
++
++    if (prevmhp.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevmhp.label);
++        sx += strlen(prevmhp.label);
++    }
++
++    if (prevmhp.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevmhp.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevmhp.txt);
++        curses_toggle_color_attr(win, prevmhp.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevmhp.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevmhp.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Power */
++    if (u.uen != prevpow.value)
++	{
++	    if (u.uen > prevpow.value)
++	    {
++	        prevpow.highlight_color = STAT_UP_COLOR;
++	    }
++	    else
++	    {
++            prevpow.highlight_color = STAT_DOWN_COLOR;
++	    }
++        prevpow.value = u.uen;
++        sprintf(buf, "%d", u.uen);
++        free(prevpow.txt);
++        prevpow.txt = curses_copy_of(buf);
++        prevpow.highlight_turns = 3;
++	}
++
++    if (prevpow.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevpow.label);
++        sx += strlen(prevpow.label);
++    }
++
++    if (prevpow.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevpow.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevpow.txt);
++        curses_toggle_color_attr(win, prevpow.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevpow.txt);
++    }
++    
++    sx += strlen(prevpow.txt);
++
++    /* Max Power */
++    if (u.uenmax != prevmpow.value)
++	{
++	    if (u.uenmax > prevmpow.value)
++	    {
++	        prevmpow.highlight_color = STAT_UP_COLOR;
++	    }
++	    else
++	    {
++            prevmpow.highlight_color = STAT_DOWN_COLOR;
++	    }
++        prevmpow.value = u.uenmax;
++        sprintf(buf, "%d", u.uenmax);
++        free(prevmpow.txt);
++        prevmpow.txt = curses_copy_of(buf);
++        prevmpow.highlight_turns = 3;
++	}
++
++    if (prevmpow.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevmpow.label);
++        sx += strlen(prevmpow.label);
++    }
++
++    if (prevmpow.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevmpow.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevmpow.txt);
++        curses_toggle_color_attr(win, prevmpow.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevmpow.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevmpow.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++
++    /* Armor Class */
++    if (u.uac != prevac.value)
++	{
++	    if (u.uac > prevac.value)   /* Lower is better for AC */
++	    {
++	        prevac.highlight_color = STAT_DOWN_COLOR;
++	    }
++	    else
++	    {
++            prevac.highlight_color = STAT_UP_COLOR;
++	    }
++        prevac.value = u.uac;
++        sprintf(buf, "%d", u.uac);
++        free(prevac.txt);
++        prevac.txt = curses_copy_of(buf);
++        prevac.highlight_turns = 5;
++	}
++
++    if (prevac.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevac.label);
++        sx += strlen(prevac.label);
++    }
++
++    if (prevac.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevac.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevac.txt);
++        curses_toggle_color_attr(win, prevac.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevac.txt);
++    }
++    
++    if (horiz)
++    {
++        sx += strlen(prevac.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Experience */
++#ifdef EXP_ON_BOTL
++    if (prevexp.display != flags.showexp)   /* Setting has changed */
++    {
++        prevexp.display = flags.showexp;
++        free(prevlevel.label);
++        if (prevexp.display)
++        {
++            prevlevel.label = curses_copy_of("/");
++        }
++        else
++        {
++            prevlevel.label = curses_copy_of("Lvl:");
++        }
++    }
++
++    if (prevexp.display && !u.mtimedone)
++    {
++        if (u.uexp != prevexp.value)
++	    {
++	        if (u.uexp > prevexp.value)
++	        {
++	            prevexp.highlight_color = STAT_UP_COLOR;
++	        }
++	        else
++	        {
++                prevexp.highlight_color = STAT_DOWN_COLOR;
++	        }
++            sprintf(buf, "%d", u.uexp);
++            free(prevexp.txt);
++            prevexp.txt = curses_copy_of(buf);
++            prevexp.highlight_turns = 3;
++	    }
++
++        if (prevexp.label != NULL)
++        {
++            mvwaddstr(win, sy, sx, prevexp.label);
++            sx += strlen(prevexp.label);
++        }
++
++        if (prevexp.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevexp.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevexp.txt);
++            curses_toggle_color_attr(win, prevexp.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevexp.txt);
++        }
++
++        sx += strlen(prevexp.txt);
++    }
++    
++    prevexp.value = u.uexp; /* Track it even when it's not displayed */
++#endif  /* EXP_ON_BOTL */
++
++    /* Level */
++    if (u.mtimedone)    /* Currently polymorphed - show monster HD */
++    {
++        if (strncmp(prevlevel.label, "HD:", 3) != 0)
++        {
++            free(prevlevel.label);
++            prevlevel.label = curses_copy_of("HD:");
++        }
++        if (mons[u.umonnum].mlevel != prevlevel.value)
++        {
++            if (mons[u.umonnum].mlevel > prevlevel.value)
++            {
++                prevlevel.highlight_color = STAT_UP_COLOR;
++            }
++            else
++            {
++                prevlevel.highlight_color = STAT_DOWN_COLOR;
++            }
++            prevlevel.highlight_turns = 5;
++        }
++        prevlevel.value = mons[u.umonnum].mlevel;
++        sprintf(buf, "%d", mons[u.umonnum].mlevel);
++        free(prevlevel.txt);
++        prevlevel.txt = curses_copy_of(buf);
++    }
++    else    /* Not polymorphed */
++    {
++        if (strncmp(prevlevel.label, "HD:", 3) == 0)
++        {
++            free(prevlevel.label);
++            if (prevexp.display)
++            {
++                prevlevel.label = curses_copy_of("/");
++            }
++            else
++            {
++                prevlevel.label = curses_copy_of("Lvl:");
++            }
++        }
++        if (u.ulevel > prevlevel.value)
++        {
++            prevlevel.highlight_color = STAT_UP_COLOR;
++            prevlevel.highlight_turns = 5;
++        }
++        else if (u.ulevel < prevlevel.value)
++        {
++            prevlevel.highlight_color = STAT_DOWN_COLOR;
++            prevlevel.highlight_turns = 5;
++        }
++        prevlevel.value = u.ulevel;
++        sprintf(buf, "%d", u.ulevel);
++        free(prevlevel.txt);
++        prevlevel.txt = curses_copy_of(buf);
++    }
++
++    if (prevlevel.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevlevel.label);
++        sx += strlen(prevlevel.label);
++    }
++
++    if (prevlevel.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevlevel.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevlevel.txt);
++        curses_toggle_color_attr(win, prevlevel.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevlevel.txt);
++    }
++
++    if (horiz)
++    {
++        sx += strlen(prevlevel.txt) + 1;
++    }
++    else
++    {
++        sx = sx_start;
++        sy++;
++    }
++
++    /* Time */
++    if (prevtime.display != flags.time)   /* Setting has changed */
++    {
++        prevtime.display = flags.time;
++    }
++    if (prevtime.display)
++    {
++        if (moves != prevtime.value)
++	    {
++            sprintf(buf, "%ld", moves);
++            free(prevtime.txt);
++            prevtime.txt = curses_copy_of(buf);
++	    }
++
++        if (prevtime.label != NULL)
++        {
++            mvwaddstr(win, sy, sx, prevtime.label);
++            sx += strlen(prevtime.label);
++        }
++
++        mvwaddstr(win, sy, sx, prevtime.txt);
++
++        if (horiz)
++        {
++            sx += strlen(prevtime.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++    
++    /* Score */
++#ifdef SCORE_ON_BOTL
++    if (prevscore.display != flags.showscore)   /* Setting has changed */
++    {
++        prevscore.display = flags.showscore;
++    }
++    if (prevscore.display)
++    {
++        if (botl_score() != prevscore.value)
++	    {
++	        if (botl_score() > prevscore.value)
++	        {
++	            prevscore.highlight_color = STAT_UP_COLOR;
++	        }
++	        else    /* Not sure this is possible */
++	        {
++                prevscore.highlight_color = STAT_DOWN_COLOR;
++	        }
++            sprintf(buf, "%ld", botl_score());
++            free(prevscore.txt);
++            prevscore.txt = curses_copy_of(buf);
++            prevscore.highlight_turns = 3;
++	    }
++
++        if (prevscore.label != NULL)
++        {
++            mvwaddstr(win, sy, sx, prevscore.label);
++            sx += strlen(prevscore.label);
++        }
++
++        if (prevscore.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevscore.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevscore.txt);
++            curses_toggle_color_attr(win, prevscore.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevscore.txt);
++        }
++
++        if (horiz)
++        {
++            sx += strlen(prevscore.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++    
++    prevscore.value = botl_score(); /* Track it even when it's not displayed */
++#endif  /* SCORE_ON_BOTL */
++
++    /* Hunger */
++    if (u.uhs != prevhunger.value)
++	{
++	    if ((u.uhs > prevhunger.value) || (u.uhs > 3))
++	    {
++	        prevhunger.highlight_color = STAT_DOWN_COLOR;
++	    }
++	    else
++	    {
++            prevhunger.highlight_color = STAT_UP_COLOR;
++	    }
++        prevhunger.value = u.uhs;
++        for (count = 0; count < strlen(hu_stat[u.uhs]); count++)
++        {
++            if ((hu_stat[u.uhs][count]) == ' ')
++            {
++                break;
++            }
++            buf[count] = hu_stat[u.uhs][count];
++        }
++
++        buf[count] = '\0';
++        free(prevhunger.txt);
++        prevhunger.txt = curses_copy_of(buf);
++        prevhunger.highlight_turns = 5;
++	}
++
++    if (prevhunger.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevhunger.label);
++        sx += strlen(prevhunger.label);
++    }
++
++    if (prevhunger.highlight_turns > 0)
++    {
++        curses_toggle_color_attr(win, prevhunger.highlight_color, NONE, ON);
++        mvwaddstr(win, sy, sx, prevhunger.txt);
++        curses_toggle_color_attr(win, prevhunger.highlight_color, NONE, OFF);
++    }
++    else
++    {
++        mvwaddstr(win, sy, sx, prevhunger.txt);
++    }
++    
++    if (strlen(prevhunger.txt) > 0)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevhunger.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    /* Confusion */
++    if (Confusion != prevconf.value)
++	{
++	    prevconf.highlight_color = STAT_DOWN_COLOR;
++        if (prevconf.txt != NULL)
++        {
++            free(prevconf.txt);
++        }
++        if (Confusion)
++        {
++            prevconf.txt = curses_copy_of("Conf");
++        }
++        else
++        {
++            prevconf.txt = NULL;
++        }
++        if (prevconf.value == 0)
++        {
++            prevconf.highlight_turns = 5;
++	    }
++        prevconf.value = Confusion;
++	}
++
++    if (prevconf.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevconf.label);
++        sx += strlen(prevconf.label);
++    }
++
++    if (prevconf.txt != NULL)
++    {
++        if (prevconf.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevconf.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevconf.txt);
++            curses_toggle_color_attr(win, prevconf.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevconf.txt);
++        }
++    }
++
++    if (prevconf.txt != NULL)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevconf.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    /* Blindness */
++    if (Blind != prevblind.value)
++	{
++	    prevblind.highlight_color = STAT_DOWN_COLOR;
++        if (prevblind.txt != NULL)
++        {
++            free(prevblind.txt);
++        }
++        if (Blind)
++        {
++            prevblind.txt = curses_copy_of("Blind");
++        }
++        else
++        {
++            prevblind.txt = NULL;
++        }
++        if (prevblind.value == 0)
++        {
++            prevblind.highlight_turns = 5;
++	    }
++        prevblind.value = Blind;
++	}
++
++    if (prevblind.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevblind.label);
++        sx += strlen(prevblind.label);
++    }
++
++    if (prevblind.txt != NULL)
++    {
++        if (prevblind.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevblind.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevblind.txt);
++            curses_toggle_color_attr(win, prevblind.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevblind.txt);
++        }
++    }
++
++    if (prevblind.txt != NULL)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevblind.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    /* Stun */
++    if (Stunned != prevstun.value)
++	{
++	    prevstun.highlight_color = STAT_DOWN_COLOR;
++        if (prevstun.txt != NULL)
++        {
++            free(prevstun.txt);
++        }
++        if (Stunned)
++        {
++            prevstun.txt = curses_copy_of("Stun");
++        }
++        else
++        {
++            prevstun.txt = NULL;
++        }
++        if (prevstun.value == 0)
++        {
++            prevstun.highlight_turns = 5;
++	    }
++        prevstun.value = Stunned;
++	}
++
++    if (prevstun.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevstun.label);
++        sx += strlen(prevstun.label);
++    }
++
++    if (prevstun.txt != NULL)
++    {
++        if (prevstun.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevstun.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevstun.txt);
++            curses_toggle_color_attr(win, prevstun.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevstun.txt);
++        }
++    }
++
++    if (prevstun.txt != NULL)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevstun.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    /* Hallucination */
++    if (Hallucination != prevhallu.value)
++	{
++	    prevhallu.highlight_color = STAT_DOWN_COLOR;
++        if (prevhallu.txt != NULL)
++        {
++            free(prevhallu.txt);
++        }
++        if (Hallucination)
++        {
++            prevhallu.txt = curses_copy_of("Hallu");
++        }
++        else
++        {
++            prevhallu.txt = NULL;
++        }
++        if (prevhallu.value == 0)
++        {
++            prevhallu.highlight_turns = 5;
++	    }
++        prevhallu.value = Hallucination;
++	}
++
++    if (prevhallu.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevhallu.label);
++        sx += strlen(prevhallu.label);
++    }
++
++    if (prevhallu.txt != NULL)
++    {
++        if (prevhallu.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevhallu.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevhallu.txt);
++            curses_toggle_color_attr(win, prevhallu.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevhallu.txt);
++        }
++    }
++
++    if (prevhallu.txt != NULL)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevhallu.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    /* Sick */
++    if (Sick != prevsick.value)
++	{
++	    prevsick.highlight_color = STAT_DOWN_COLOR;
++        if (prevsick.txt != NULL)
++        {
++            free(prevsick.txt);
++        }
++        if (Sick)
++        {
++            if (u.usick_type & SICK_VOMITABLE)
++            {
++                prevsick.txt = curses_copy_of("FoodPois");
++            }
++            else      
++            {
++                prevsick.txt = curses_copy_of("Ill");
++            }
++        }
++        else
++        {
++            prevsick.txt = NULL;
++        }
++        if (prevsick.value == 0)
++        {
++            prevsick.highlight_turns = 5;
++	    }
++        prevsick.value = Sick;
++	}
++
++    if (prevsick.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevsick.label);
++        sx += strlen(prevsick.label);
++    }
++
++    if (prevsick.txt != NULL)
++    {
++        if (prevsick.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevsick.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevsick.txt);
++            curses_toggle_color_attr(win, prevsick.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevsick.txt);
++        }
++    }
++
++    if (prevsick.txt != NULL)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevsick.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    /* Slime */
++    if (Slimed != prevslime.value)
++	{
++	    prevslime.highlight_color = STAT_DOWN_COLOR;
++        if (prevslime.txt != NULL)
++        {
++            free(prevslime.txt);
++        }
++        if (Slimed)
++        {
++            prevslime.txt = curses_copy_of("Slime");
++        }
++        else
++        {
++            prevslime.txt = NULL;
++        }
++        if (prevslime.value == 0)
++        {
++            prevslime.highlight_turns = 5;
++	    }
++        prevslime.value = Slimed;
++	}
++
++    if (prevslime.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevslime.label);
++        sx += strlen(prevslime.label);
++    }
++
++    if (prevslime.txt != NULL)
++    {
++        if (prevslime.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevslime.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevslime.txt);
++            curses_toggle_color_attr(win, prevslime.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevslime.txt);
++        }
++    }
++
++    if (prevslime.txt != NULL)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevslime.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    /* Encumberance */
++    enc = near_capacity();
++    
++    if (enc != prevencumb.value)
++	{
++	    if (enc < prevencumb.value)
++	    {
++	        prevencumb.highlight_color = STAT_UP_COLOR;
++	    }
++	    else
++	    {
++	        prevencumb.highlight_color = STAT_DOWN_COLOR;
++        }
++        if (prevencumb.txt != NULL)
++        {
++            free(prevencumb.txt);
++        }
++        if (enc > UNENCUMBERED)
++        {
++            sprintf(buf, "%s", enc_stat[enc]);
++            prevencumb.txt = curses_copy_of(buf);
++            prevencumb.highlight_turns = 5;
++        }
++        else
++        {
++            prevencumb.txt = NULL;
++        }
++        prevencumb.value = enc;
++	}
++
++    if (prevencumb.label != NULL)
++    {
++        mvwaddstr(win, sy, sx, prevencumb.label);
++        sx += strlen(prevencumb.label);
++    }
++
++    if (prevencumb.txt != NULL)
++    {
++        if (prevencumb.highlight_turns > 0)
++        {
++            curses_toggle_color_attr(win, prevencumb.highlight_color, NONE, ON);
++            mvwaddstr(win, sy, sx, prevencumb.txt);
++            curses_toggle_color_attr(win, prevencumb.highlight_color, NONE, OFF);
++        }
++        else
++        {
++            mvwaddstr(win, sy, sx, prevencumb.txt);
++        }
++    }
++
++    if (prevencumb.txt != NULL)
++    {
++        if (horiz)
++        {
++            sx += strlen(prevencumb.txt) + 1;
++        }
++        else
++        {
++            sx = sx_start;
++            sy++;
++        }
++    }
++
++    wrefresh(win);
++}
++
++
++/* Decrement the highlight_turns for all stats.  Call curses_update_stats
++if needed to unhighlight a stat */
++
++void curses_decrement_highlight()
++{
++    boolean unhighlight = FALSE;
++    
++    if (prevname.highlight_turns > 0)
++    {
++        prevname.highlight_turns--;
++        if (prevname.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevdepth.highlight_turns > 0)
++    {
++        prevdepth.highlight_turns--;
++        if (prevdepth.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevstr.highlight_turns > 0)
++    {
++        prevstr.highlight_turns--;
++        if (prevstr.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevint.highlight_turns > 0)
++    {
++        prevint.highlight_turns--;
++        if (prevint.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevwis.highlight_turns > 0)
++    {
++        prevwis.highlight_turns--;
++        if (prevwis.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevdex.highlight_turns > 0)
++    {
++        prevdex.highlight_turns--;
++        if (prevdex.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevcon.highlight_turns > 0)
++    {
++        prevcon.highlight_turns--;
++        if (prevcon.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevcha.highlight_turns > 0)
++    {
++        prevcha.highlight_turns--;
++        if (prevcha.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevalign.highlight_turns > 0)
++    {
++        prevalign.highlight_turns--;
++        if (prevalign.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevau.highlight_turns > 0)
++    {
++        prevau.highlight_turns--;
++        if (prevau.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevhp.highlight_turns > 0)
++    {
++        prevhp.highlight_turns--;
++        if (prevhp.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevmhp.highlight_turns > 0)
++    {
++        prevmhp.highlight_turns--;
++        if (prevmhp.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevlevel.highlight_turns > 0)
++    {
++        prevlevel.highlight_turns--;
++        if (prevlevel.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevpow.highlight_turns > 0)
++    {
++        prevpow.highlight_turns--;
++        if (prevpow.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevmpow.highlight_turns > 0)
++    {
++        prevmpow.highlight_turns--;
++        if (prevmpow.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevac.highlight_turns > 0)
++    {
++        prevac.highlight_turns--;
++        if (prevac.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++#ifdef EXP_ON_BOTL
++    if (prevexp.highlight_turns > 0)
++    {
++        prevexp.highlight_turns--;
++        if (prevexp.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++#endif
++    if (prevtime.highlight_turns > 0)
++    {
++        prevtime.highlight_turns--;
++        if (prevtime.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++#ifdef SCORE_ON_BOTL
++    if (prevscore.highlight_turns > 0)
++    {
++        prevscore.highlight_turns--;
++        if (prevscore.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++#endif
++    if (prevhunger.highlight_turns > 0)
++    {
++        prevhunger.highlight_turns--;
++        if (prevhunger.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevconf.highlight_turns > 0)
++    {
++        prevconf.highlight_turns--;
++        if (prevconf.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevblind.highlight_turns > 0)
++    {
++        prevblind.highlight_turns--;
++        if (prevblind.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevstun.highlight_turns > 0)
++    {
++        prevstun.highlight_turns--;
++        if (prevstun.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevhallu.highlight_turns > 0)
++    {
++        prevhallu.highlight_turns--;
++        if (prevhallu.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevsick.highlight_turns > 0)
++    {
++        prevsick.highlight_turns--;
++        if (prevsick.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevslime.highlight_turns > 0)
++    {
++        prevslime.highlight_turns--;
++        if (prevslime.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    if (prevencumb.highlight_turns > 0)
++    {
++        prevencumb.highlight_turns--;
++        if (prevencumb.highlight_turns == 0)
++        {
++            unhighlight = TRUE;
++        }
++    }
++    
++    if (unhighlight)
++    {
++        curses_update_stats();
++    }
++}
++
++
++/* Initialize the stats with beginning values. */
++
++static void init_stats()
++{
++    char buf[BUFSZ];
++    int count;
++
++    /* Player name and title */
++    strcpy(buf, plname);
++    if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a';
++    strcat(buf, " the ");
++    if (u.mtimedone) {
++        char mname[BUFSZ];
++        int k = 0;
++
++        strcpy(mname, mons[u.umonnum].mname);
++        while(mname[k] != 0) {
++            if ((k == 0 || (k > 0 && mname[k-1] == ' '))
++             && 'a' <= mname[k] && mname[k] <= 'z')
++            {
++                mname[k] += 'A' - 'a';
++            }
++            k++;
++        }
++        strcat(buf, mname);
++    } else {
++        strcat(buf, rank_of(u.ulevel, pl_character[0], flags.female));
++    }
++
++    prevname.txt = curses_copy_of(buf);
++    prevname.display = TRUE;
++    prevname.highlight_turns = 0;
++    prevname.label = NULL;
++    
++    /* Strength */
++    if (ACURR(A_STR) > 118)
++    {
++        sprintf(buf, "%d", ACURR(A_STR) - 100);
++    }
++    else if (ACURR(A_STR)==118)
++    {
++        sprintf(buf, "18/**");
++    }
++    else if(ACURR(A_STR) > 18)
++    {
++        sprintf(buf, "18/%02d", ACURR(A_STR) - 18);
++    }
++    else
++    {
++        sprintf(buf, "%d", ACURR(A_STR));
++    }
++
++    prevstr.value = ACURR(A_STR);
++    prevstr.txt = curses_copy_of(buf);
++    prevstr.display = TRUE;
++    prevstr.highlight_turns = 0;
++    prevstr.label = curses_copy_of("Str:");
++
++    /* Intelligence */
++    sprintf(buf, "%d", ACURR(A_INT));
++    prevint.value = ACURR(A_INT);
++    prevint.txt = curses_copy_of(buf);
++    prevint.display = TRUE;
++    prevint.highlight_turns = 0;
++    prevint.label = curses_copy_of("Int:");
++
++    /* Wisdom */
++    sprintf(buf, "%d", ACURR(A_WIS));
++    prevwis.value = ACURR(A_WIS);
++    prevwis.txt = curses_copy_of(buf);
++    prevwis.display = TRUE;
++    prevwis.highlight_turns = 0;
++    prevwis.label = curses_copy_of("Wis:");
++
++    /* Dexterity */
++    sprintf(buf, "%d", ACURR(A_DEX));
++    prevdex.value = ACURR(A_DEX);
++    prevdex.txt = curses_copy_of(buf);
++    prevdex.display = TRUE;
++    prevdex.highlight_turns = 0;
++    prevdex.label = curses_copy_of("Dex:");
++
++    /* Constitution */
++    sprintf(buf, "%d", ACURR(A_CON));
++    prevcon.value = ACURR(A_CON);
++    prevcon.txt = curses_copy_of(buf);
++    prevcon.display = TRUE;
++    prevcon.highlight_turns = 0;
++    prevcon.label = curses_copy_of("Con:");
++
++    /* Charisma */
++    sprintf(buf, "%d", ACURR(A_CHA));
++    prevcha.value = ACURR(A_CHA);
++    prevcha.txt = curses_copy_of(buf);
++    prevcha.display = TRUE;
++    prevcha.highlight_turns = 0;
++    prevcha.label = curses_copy_of("Cha:");
++
++    /* Alignment */
++    switch (u.ualign.type)
++    {
++        case A_LAWFUL:
++        {
++            prevalign.txt = curses_copy_of("Lawful");
++            break;
++        }
++        case A_NEUTRAL:
++        {
++            prevalign.txt = curses_copy_of("Neutral");
++            break;
++        }
++        case A_CHAOTIC:
++        {
++            prevalign.txt = curses_copy_of("Chaotic");
++            break;
++        }
++    }
++    
++    prevalign.alignment = u.ualign.type;
++    prevalign.display = TRUE;
++    prevalign.highlight_turns = 0;
++    prevalign.label = NULL;
++    
++    /* Dungeon level */
++    if (In_endgame(&u.uz))
++    {
++        strcpy(buf, (Is_astralevel(&u.uz) ? "Astral Plane":"End Game"));
++    }
++    else
++    {
++        sprintf(buf, "%d", depth(&u.uz));
++    }
++
++    prevdepth.value = depth(&u.uz);
++    prevdepth.txt = curses_copy_of(buf);
++    prevdepth.display = TRUE;
++    prevdepth.highlight_turns = 0;
++    prevdepth.label = curses_copy_of("Dlvl:");
++    
++    /* Gold */
++#ifndef GOLDOBJ
++    sprintf(buf,"%ld", u.ugold);
++    prevau.value = u.ugold;
++#else
++    sprintf(buf,"%ld", money_cnt(invent));
++    prevau.value = money_cnt(invent);
++#endif
++    prevau.txt = curses_copy_of(buf);
++    prevau.display = TRUE;
++    prevau.highlight_turns = 0;
++    sprintf(buf, "%c:", GOLD_SYM);
++    prevau.label = curses_copy_of(buf);
++
++    /* Hit Points */
++    if (u.mtimedone)    /* Currently polymorphed - show monster HP */
++    {
++        prevhp.value = u.mh;
++        sprintf(buf, "%d", u.mh);
++        prevhp.txt = curses_copy_of(buf);
++	}
++	else if (u.uhp != prevhp.value)  /* Not polymorphed */
++	{
++	    prevhp.value = u.uhp;
++        sprintf(buf, "%d", u.uhp);
++        prevhp.txt = curses_copy_of(buf);
++	}
++	prevhp.display = TRUE;
++	prevhp.highlight_turns = 0;
++    prevhp.label = curses_copy_of("HP:");
++
++    /* Max Hit Points */
++    if (u.mtimedone)    /* Currently polymorphed - show monster HP */
++    {
++        prevmhp.value = u.mhmax;
++        sprintf(buf, "%d", u.mhmax);
++        prevmhp.txt = curses_copy_of(buf);
++	}
++	else    /* Not polymorphed */
++	{
++	    prevmhp.value = u.uhpmax;
++        sprintf(buf, "%d", u.uhpmax);
++        prevmhp.txt = curses_copy_of(buf);
++	}
++	prevmhp.display = TRUE;
++	prevmhp.highlight_turns = 0;
++    prevmhp.label = curses_copy_of("/");
++
++    /* Power */
++    prevpow.value = u.uen;
++    sprintf(buf, "%d", u.uen);
++    prevpow.txt = curses_copy_of(buf);
++	prevpow.display = TRUE;
++	prevpow.highlight_turns = 0;
++    prevpow.label = curses_copy_of("Pw:");
++
++    /* Max Power */
++    prevmpow.value = u.uenmax;
++    sprintf(buf, "%d", u.uenmax);
++    prevmpow.txt = curses_copy_of(buf);
++	prevmpow.display = TRUE;
++	prevmpow.highlight_turns = 0;
++    prevmpow.label = curses_copy_of("/");
++
++    /* Armor Class */
++    prevac.value = u.uac;
++    sprintf(buf, "%d", u.uac);
++    prevac.txt = curses_copy_of(buf);
++	prevac.display = TRUE;
++	prevac.highlight_turns = 0;
++    prevac.label = curses_copy_of("AC:");
++
++    /* Experience */
++#ifdef EXP_ON_BOTL
++    prevexp.value = u.uexp;
++    sprintf(buf, "%ld", u.uexp);
++    prevexp.txt = curses_copy_of(buf);
++	prevexp.display = flags.showexp;
++	prevexp.highlight_turns = 0;
++    prevexp.label = curses_copy_of("Xp:");
++#endif
++
++    /* Level */
++    if (u.mtimedone)    /* Currently polymorphed - show monster HP */
++    {
++        prevlevel.value = mons[u.umonnum].mlevel;
++        sprintf(buf, "%d", mons[u.umonnum].mlevel);
++        prevlevel.txt = curses_copy_of(buf);
++        prevlevel.label = curses_copy_of("HD:");
++	}
++	else if (u.ulevel != prevlevel.value)  /* Not polymorphed */
++	{
++	    prevlevel.value = u.ulevel;
++        sprintf(buf, "%d", u.ulevel);
++        prevlevel.txt = curses_copy_of(buf);
++        if (prevexp.display)
++        {
++            prevlevel.label = curses_copy_of("/");
++        }
++        else
++        {    
++            prevlevel.label = curses_copy_of("Lvl:");
++        }
++	}
++	prevlevel.display = TRUE;
++	prevlevel.highlight_turns = 0;
++
++    /* Time */
++    prevtime.value = moves;
++    sprintf(buf, "%ld", moves);
++    prevtime.txt = curses_copy_of(buf);
++	prevtime.display = flags.time;
++	prevtime.highlight_turns = 0;
++    prevtime.label = curses_copy_of("T:");
++
++    /* Score */
++#ifdef SCORE_ON_BOTL
++    prevscore.value = botl_score();
++    sprintf(buf, "%ld", botl_score());
++    prevscore.txt = curses_copy_of(buf);
++	prevscore.display = flags.showscore;
++	prevscore.highlight_turns = 0;
++    prevscore.label = curses_copy_of("S:");
++#endif
++
++    /* Hunger */
++    prevhunger.value = u.uhs;
++    for (count = 0; count < strlen(hu_stat[u.uhs]); count++)
++    {
++        if ((hu_stat[u.uhs][count]) == ' ')
++        {
++            break;
++        }
++        buf[count] = hu_stat[u.uhs][count];
++    }
++
++    buf[count] = '\0';
++    prevhunger.txt = curses_copy_of(buf);
++    prevhunger.display = TRUE;
++    prevhunger.highlight_turns = 0;
++    prevhunger.label = NULL;
++
++    /* Confusion */
++    prevconf.value = Confusion;
++    if (Confusion)
++    {
++        prevconf.txt = curses_copy_of("Conf");
++    }
++    else
++    {
++        prevconf.txt = NULL;
++    }
++    prevconf.display = TRUE;
++    prevconf.highlight_turns = 0;
++    prevconf.label = NULL;
++
++    /* Blindness */
++    prevblind.value = Blind;
++    if (Blind)
++    {
++        prevblind.txt = curses_copy_of("Blind");
++    }
++    else
++    {
++        prevblind.txt = NULL;
++    }
++    prevblind.display = TRUE;
++    prevblind.highlight_turns = 0;
++    prevblind.label = NULL;
++
++    /* Stun */
++    prevstun.value = Stunned;
++    if (Stunned)
++    {
++        prevstun.txt = curses_copy_of("Stun");
++    }
++    else
++    {
++        prevstun.txt = NULL;
++    }
++    prevstun.display = TRUE;
++    prevstun.highlight_turns = 0;
++    prevstun.label = NULL;
++
++    /* Hallucination */
++    prevhallu.value = Hallucination;
++    if (Hallucination)
++    {
++        prevhallu.txt = curses_copy_of("Hallu");
++    }
++    else
++    {
++        prevhallu.txt = NULL;
++    }
++    prevhallu.display = TRUE;
++    prevhallu.highlight_turns = 0;
++    prevhallu.label = NULL;
++
++    /* Sick */
++    prevsick.value = Sick;
++    if (Sick)
++    {
++        if (u.usick_type & SICK_VOMITABLE)
++        {
++            prevsick.txt = curses_copy_of("Sick");
++        }
++        else     
++        {
++            prevsick.txt = curses_copy_of("Ill");
++        }
++    }
++    else
++    {
++        prevsick.txt = NULL;
++    }
++    prevsick.display = TRUE;
++    prevsick.highlight_turns = 0;
++    prevsick.label = NULL;
++
++    /* Slimed */
++    prevslime.value = Slimed;
++    if (Slimed)
++    {
++        prevslime.txt = curses_copy_of("Slime");
++    }
++    else
++    {
++        prevslime.txt = NULL;
++    }
++    prevslime.display = TRUE;
++    prevslime.highlight_turns = 0;
++    prevslime.label = NULL;
++
++    /* Encumberance */
++    prevencumb.value = near_capacity();
++    if (prevencumb.value > UNENCUMBERED)
++    {
++        sprintf(buf, "%s", enc_stat[prevencumb.value]);
++        prevencumb.txt = curses_copy_of(buf);
++    }
++    else
++    {
++        prevencumb.txt = NULL;
++    }
++    prevencumb.display = TRUE;
++    prevencumb.highlight_turns = 0;
++    prevencumb.label = NULL;
++}
++
+diff -burN nethack-3.4.3/win/curses/cursstat.h nethack/win/curses/cursstat.h
+--- nethack-3.4.3/win/curses/cursstat.h	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/cursstat.h	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,29 @@
++#ifndef CURSSTAT_H
++#define CURSSTAT_H
++
++
++/* Global declarations */
++
++void curses_update_stats(void);
++
++void curses_decrement_highlight(void);
++
++
++/* Private declarations */
++
++typedef struct nhs
++{
++    long value;
++    char *txt;
++    aligntyp alignment;
++    boolean display;
++    int highlight_turns;
++    int highlight_color;
++    int x;
++    int y;
++    char *label;
++} nhstat;
++
++static void init_stats(void);
++
++#endif  /* CURSSTAT_H */
+diff -burN nethack-3.4.3/win/curses/curswins.c nethack/win/curses/curswins.c
+--- nethack-3.4.3/win/curses/curswins.c	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/curswins.c	2009-03-11 15:08:53.000000000 -0400
+@@ -0,0 +1,462 @@
++#include "curses.h"
++#include "hack.h"
++#include "wincurs.h"
++#include "curswins.h"
++
++/* Window handling for curses interface */
++
++static nethack_window *nhwins = NULL;  /* NetHack window array */
++
++
++
++/* Create a window with the specified size and orientation */
++
++WINDOW *curses_create_window(int width, int height, orient orientation)
++{
++    int mapx, mapy, maph, mapw = 0;
++    int startx = 0;
++    int starty = 0;
++    WINDOW *win;
++    boolean map_border = FALSE;
++        
++    if ((orientation == UP) || (orientation == DOWN) ||
++     (orientation == LEFT))
++    {
++        map_border = curses_window_has_border(MAP_WIN);
++        curses_get_window_xy(MAP_WIN, &mapx, &mapy);
++        curses_get_window_size(MAP_WIN, &maph, &mapw);
++    }
++    width += 2;    /* leave room for bounding box */
++    height += 2;
++    if ((width > term_cols) || (height > term_rows))
++        panic("curses_create_window: Terminal too small for dialog window");
++    switch (orientation)
++    {
++        case CENTER:
++        {
++            startx = (term_cols / 2) - (width / 2);
++            starty = (term_rows / 2) - (height / 2);
++            break;
++        }
++        case UP:
++        {
++            startx = (mapw / 2) - (width / 2) + mapx;
++            starty = mapy;
++            break;
++        }
++        case DOWN:
++        {
++            startx = (mapw / 2) - (width / 2) + mapx;
++            starty = height - mapy - 1;
++            break;
++        }
++        case LEFT:
++        {
++            if (map_border && (width < term_cols))
++                startx = 1;
++            else
++                startx = 0;
++            starty = term_rows - height;
++            break;
++        }
++        case RIGHT:
++        {
++            startx = term_cols - width;
++            starty = 0;
++            break;
++        }
++        default:
++        {
++            panic("curses_create_window: Bad orientation");
++        }
++    }
++    win = newwin(height, width, starty, startx);
++    curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON);
++    box(win, 0, 0);
++    curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF);
++    return win;
++}
++
++
++/* Erase and delete curses window, and refresh standard windows */
++
++void curses_destroy_win(WINDOW *win)
++{
++    werase(win);
++    wrefresh(win);
++    delwin(win);
++    curses_refresh_nethack_windows();
++}
++
++
++/* Refresh nethack windows if they exist, or base window if not */
++
++void curses_refresh_nethack_windows()
++{
++    WINDOW *status_window, *message_window;
++    
++    status_window = curses_get_nhwin(STATUS_WIN);
++    message_window = curses_get_nhwin(MESSAGE_WIN);
++    
++    if (!iflags.window_inited)
++    {
++        /* Main windows not yet displayed; refresh base window instead */
++        touchwin(stdscr);
++        refresh();
++    }
++    else
++    {
++        touchwin(status_window);
++        wnoutrefresh(status_window);
++        box(mapborderwin, 0, 0);
++        wrefresh(mapborderwin);
++        touchwin(message_window);
++        wnoutrefresh(message_window);
++        doupdate();
++        refresh_map_window();
++    }
++}
++
++
++/* Return curses window pointer for given NetHack winid */
++
++WINDOW *curses_get_nhwin(winid wid)
++{
++    nethack_window *winptr = nhwins;
++ 
++    while (winptr != NULL)
++    {
++        if (winptr->nhwin == wid)
++            return winptr->curwin;
++        winptr = winptr->next_window;
++    }
++    
++    return NULL;    /* Not found */
++}
++
++
++/* Add curses window pointer and window info to list for given NetHack winid */
++
++void curses_add_nhwin(winid wid, int height, int width, int y, int x,
++  orient orientation, boolean border)
++{
++    WINDOW *win;
++    nethack_window *new_win;
++    nethack_window *winptr = nhwins;
++    int real_width = width;
++    int real_height = height;
++    
++    new_win = malloc(sizeof(nethack_window));
++    new_win->nhwin = wid;
++    new_win->border = border;
++    new_win->width = width;
++    new_win->height = height;
++    new_win->x = x;
++    new_win->y = y;
++    new_win->orientation = orientation;
++    if (border)
++    {
++        real_width += 2;    /* leave room for bounding box */
++        real_height += 2;
++    }
++    new_win->next_window = NULL;
++    if (winptr == NULL)
++    {
++        new_win->prev_window = NULL;
++        nhwins = new_win;
++    }
++    else
++    {
++        while (winptr->next_window != NULL)
++            winptr = winptr->next_window;
++        new_win->prev_window = winptr;
++        winptr->next_window = new_win;
++    }
++    if (wid != MAP_WIN)
++    {
++        win = newwin(real_height, real_width, y, x);
++        if (border)
++        {
++            box(win, 0, 0);
++        }
++    }
++    else
++    {
++        if (border)
++        {
++            box(mapborderwin, 0, 0);
++        }
++        win = newpad(ROWNO, COLNO);
++    }
++    new_win->curwin = win;
++}
++
++
++/* refresh a curses window via given nethack winid */
++
++void curses_refresh_nhwin(winid wid)
++{
++    if (wid != MAP_WIN)
++        wrefresh(curses_get_nhwin(wid));
++    else
++        refresh_map_window();
++}
++
++
++/* Delete curses window via given NetHack winid and remove entry from list */
++
++void curses_del_nhwin(winid wid)
++{
++    nethack_window *tmpwin;
++    nethack_window *winptr = nhwins;
++    
++    if (curses_is_menu(wid) || curses_is_text(wid))
++    {
++        curses_del_menu(wid);
++    }
++    
++    while (winptr != NULL)
++    {
++        if (winptr->nhwin == wid)
++        {
++            if (winptr->prev_window != NULL)
++            {
++                tmpwin = winptr->prev_window;
++                tmpwin->next_window = winptr->next_window;
++            }
++            else
++            {
++                nhwins = winptr->next_window;   /* New head mode, or NULL */
++            }
++            if (winptr->next_window != NULL)
++            {
++                tmpwin = winptr->next_window;
++                tmpwin->prev_window = winptr->prev_window;
++            }
++            free(winptr);
++            break;
++        }
++        winptr = winptr->next_window;
++    }
++}
++
++
++/* Print a single character in the given window at the given coordinates */
++
++void curses_putch(winid wid, int x, int y, int ch, int color, int attr)
++{
++    WINDOW *win;
++    boolean border = curses_window_has_border(wid);
++    
++    if (border && (wid != MAP_WIN))
++    {
++        x++;
++        y++;
++    }
++    win = curses_get_nhwin(wid);
++    curses_toggle_color_attr(win, color, attr, ON);
++#ifdef PDCURSES
++    mvwaddrawch(win, y, x, ch);
++#else
++    mvwaddch(win, y, x, ch);
++#endif
++    if (wid == MAP_WIN)
++    {
++        refresh_map_window();
++    }
++else
++    {
++        wrefresh(win);
++    }
++    
++    curses_toggle_color_attr(win, color, attr, OFF);
++}
++
++
++/* Get x, y coordinates of curses window on the physical terminal window */
++
++void curses_get_window_xy(winid wid, int *x, int *y)
++{
++    nethack_window *winptr = nhwins;
++ 
++    while (winptr != NULL)
++    {
++        if (winptr->nhwin == wid)
++        {
++            *x = winptr->x;
++            *y = winptr->y;
++            break;
++        }
++        winptr = winptr->next_window;
++    }
++}
++
++
++/* Get usable width and height curses window on the physical terminal window */
++
++void curses_get_window_size(winid wid, int *height, int *width)
++{
++    nethack_window *winptr = nhwins;
++ 
++    while (winptr != NULL)
++    {
++        if (winptr->nhwin == wid)
++        {
++            *height = winptr->height;
++            *width = winptr->width;
++            break;
++        }
++        winptr = winptr->next_window;
++    }
++}
++
++
++/* Determine if given window has a visible border */
++
++boolean curses_window_has_border(winid wid)
++{
++    nethack_window *winptr = nhwins;
++ 
++    while (winptr != NULL)
++    {
++        if (winptr->nhwin == wid)
++        {
++            return winptr->border;
++        }
++        winptr = winptr->next_window;
++    }
++}
++
++
++/* Determine if window for given winid exists */
++
++boolean curses_window_exists(winid wid)
++{
++    nethack_window *winptr = nhwins;
++ 
++    while (winptr != NULL)
++    {
++        if (winptr->nhwin == wid)
++        {
++            return TRUE;
++        }
++        winptr = winptr->next_window;
++    }
++    
++    return FALSE;
++}
++
++
++/* Return the orientation of the specified window */
++
++int curses_get_window_orientation(winid wid)
++{
++    nethack_window *winptr = nhwins;
++ 
++    while (winptr != NULL)
++    {
++        if (winptr->nhwin == wid)
++        {
++            return winptr->orientation;
++        }
++        winptr = winptr->next_window;
++    }
++}
++
++
++/* Output a line of text to specified NetHack window with given coordinates
++and text attributes */
++
++void curses_puts(winid wid, int attr, const char *text)
++{
++    anything *identifier;
++    WINDOW *win = curses_get_nhwin(wid);
++    
++    curses_toggle_color_attr(win, NONE, attr, ON);
++    if (wid == MESSAGE_WIN)
++    {
++        curses_message_win_puts(text, FALSE);
++        return;
++    }
++    
++    if (wid == STATUS_WIN)
++    {
++        curses_update_stats();  /* We will do the write ourselves */
++        return;
++    }
++    
++    if (curses_is_menu(wid) || curses_is_text(wid))
++    {
++        if (!curses_menu_exists(wid))
++        {
++            panic("curses_puts: Attempted write to nonexistant window!"); 
++        }
++        identifier = malloc(sizeof(anything));
++        identifier->a_void = NULL;
++        curses_add_menu(wid, NO_GLYPH, identifier, 0, 0, attr, text,
++         FALSE);
++    }
++    else
++    {
++        waddstr(win, text);
++        wrefresh(win);
++    }
++    curses_toggle_color_attr(win, NONE, attr, OFF);
++}
++
++
++/* Clear the contents of a window via the given NetHack winid */
++
++void curses_clear_nhwin(winid wid)
++{
++    WINDOW *win = curses_get_nhwin(wid);
++    boolean border = curses_window_has_border(wid);
++    
++    werase(win);
++    if (border && (wid != MAP_WIN))
++        box(win, 0, 0);
++    if (wid != MAP_WIN)
++    {
++        wrefresh(win);
++    }
++    else
++    {
++        refresh_map_window();
++    }
++}
++
++
++/* Refresh visible portion of map window */
++
++static void refresh_map_window()
++{
++    int mapwinx, mapwiny, maph, mapw, mapwinw, mapwinh, mapx, mapy;
++    WINDOW *map_window = curses_get_nhwin(MAP_WIN);
++    boolean border = curses_window_has_border(MAP_WIN);
++    
++    curses_get_window_xy(MAP_WIN, &mapwinx, &mapwiny);
++    curses_get_window_size(MAP_WIN, &mapwinh, &mapwinw);
++    maph = ROWNO;
++    mapw = COLNO;
++    mapx = u.ux - (mapwinw / 2);
++    if ((mapx + mapwinw) > mapw)
++    {
++        mapx = mapw - mapwinw;
++    }
++    if (mapx < 0)
++    {
++        mapx = 0;
++    }
++    mapy = u.uy - (mapwinh / 2);
++    if ((mapy + mapwinh) > maph)
++    {
++        mapy = maph - mapwinh;
++    }
++    if (mapy < 0)
++    {
++        mapy = 0;
++    }
++    prefresh(map_window, mapy, mapx, mapwiny, mapwinx, mapwiny + mapwinh - 1, 
++     mapwinx + mapwinw - 1);
++}
++
+diff -burN nethack-3.4.3/win/curses/curswins.h nethack/win/curses/curswins.h
+--- nethack-3.4.3/win/curses/curswins.h	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/curswins.h	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,55 @@
++#ifndef CURSWIN_H
++#define CURSWIN_H
++
++
++/* Global declarations */
++
++WINDOW *curses_create_window(int width, int height, orient orientation);
++
++void curses_destroy_win(WINDOW *win);
++
++void curses_refresh_nethack_windows(void);
++
++WINDOW *curses_get_nhwin(winid wid);
++
++void curses_add_nhwin(winid wid, int height, int width, int y, int x,
++ orient orientation, boolean border);
++
++void curses_refresh_nhwin(winid wid);
++
++void curses_del_nhwin(winid wid);
++
++void curses_putch(winid wid, int x, int y, int ch, int color, int attrs);
++
++void curses_get_window_xy(winid wid, int *x, int *y);
++
++boolean curses_window_has_border(winid wid);
++
++boolean curses_window_exists(winid wid);
++
++int curses_get_window_orientation(winid wid);
++
++void curses_puts(winid wid, int attr, const char *text);
++
++void curses_clear_nhwin(winid wid);
++
++
++/* Private declarations */
++
++typedef struct nhw
++{
++    winid nhwin;  /* NetHack window id */
++    WINDOW *curwin; /* Curses window pointer */
++    int width;  /* Usable width not counting border */
++    int height; /* Usable height not counting border */
++    int x;  /* start of window on terminal (left) */
++    int y;  /* start of window on termial (top) */
++    int orientation;    /* Placement of window relative to map */
++    boolean border; /* Whether window has a visible border */
++    struct nhw *prev_window;    /* Pointer to previous entry */
++    struct nhw *next_window;    /* Pointer to next entry */
++} nethack_window;
++
++static void refresh_map_window(void);
++
++#endif  /* CURSWIN_H */
+diff -burN nethack-3.4.3/win/curses/Readme.txt nethack/win/curses/Readme.txt
+--- nethack-3.4.3/win/curses/Readme.txt	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/Readme.txt	2009-03-05 13:50:38.000000000 -0500
+@@ -0,0 +1,116 @@
++INTRO
++=====
++
++The "curses" windowport is a new text-based interface for NetHack,
++using high-level curses routines to control the display.  Currently, it
++has been compiled and tested on Linux and Windows, but it should also
++be portable to a number of other systems, such as other forms of UNIX,
++Mac OS X, MSDOS, and OS/2.
++
++Some features of this interface compared to the traditional tty
++interface include:
++
++ * Dynamic window resizing (e.g. maximizing a terminal window)
++ * Dynamic configurable placement of status and message windows,
++ relative to the map
++ * Makes better use of larger terminal windows
++ * Fancier display (e.g. window borders, optional popup dialogs)
++ * "cursesgraphics" option for fancier line-drawing characters for
++ drawing the dungeon - this should work on most terminals/platforms
++
++
++BUILDING
++========
++
++As of this writing code has been compiled on Linux and Windows.
++
++UNIX/Linux build instructions: Follow the instructions in
++sys/unix/Install.unx.  By default, the Makefile is setup to compile
++against ncurses.  Edit Makefile.src if you wish to compile against a
++different curses library, such as PDCurses for SDL.
++
++Windows build instructions: If you are using Mingw32 as your compiler,
++then follow the instructions in sys/winnt/Install.nt with the following
++changes:
++
++ * After running nhsetup, manually copy the file cursmake.gcc to the
++ src/ subdirectory
++ * Instead of typing "mingw32-make -f Makefile.gcc install" you will
++ type "mingw32-make -f cursmake.gcc install"
++
++If you are using a different compiler, you will have to manually modify
++the appropriate Makefile to include the curses windowport files.
++
++
++GAMEPLAY
++========
++
++Gameplay should be similar to the tty interface for NetHack; the 
++differences are primarily visual.  This windowport supports dymanic
++resizing of the terminal window, so you can play with it to see how it
++looks best to you during a game.  Also, the align_status and
++align_message options may be set during the game, so you can experiment
++to see what arraingement looks best to you.
++
++For menus, in addition to the normal configurable keybindings for menu
++navigation descrived in the Guidebook, you can use the right and left
++arrows to to forward or backward one page, respectively, and the home
++and end keys to go to the first and last pages, respectively.
++
++Some configuration options that are specific to or relevant to the
++curses windowport are shown below.  Copy any of these that you like to
++your nethack configuration file (e.g. .nethackrc for UNIX or
++NetHack.cnf for Windows):
++#
++# Use this if the binary was compiled with multiple window interfaces,
++# and curses is not the default
++OPTIONS=windowtype:curses
++#
++# Set this for Windows systems, or for PDCurses for SDL on any system.
++# The latter uses a cp437 font, which works with this option
++#OPTIONS=IBMgraphics
++#
++# Set this if IBMgraphics above won't work for your system.  Mutually
++# exclusive with the above option, and should work on nearly any
++# system.
++OPTIONS=cursesgraphics
++#
++# Optionally specify the alignment of the message and status windows
++# relative to the map window.  If not specified, the code will default
++# to the locations used in the tty interface: message window on top,
++# and status window on bottom.  Placing either of these on the right or
++# left really only works well for winder terminal windows.
++OPTIONS=align_message:bottom,align_status:right
++#
++# Use a small popup "window" for short prompts, e.g. "Really save?".
++# If this is not set, the message window will be used for these as is
++# done for the tty interface.
++OPTIONS=popup_dialog
++#
++# Specify the initial window size for NetHack in units of characters.
++# This is supported on PDCurses for SDL as well as PDCurses for
++# Windows.
++OPTIONS=term_cols:110,term_rows:32
++#
++# Controls the usage of window borders for the main NetHack windows
++# (message, map, and status windows).  A value of 1 forces the borders
++# to be drawn, a value of 2 forces them to be off, and a value of 3
++# allows the code to decide if they should be drawn based on the size
++# of the terminal window.
++OPTIONS=windowborders:3
++
++
++CONTACT
++=======
++
++Please send any bug reports, suggestions, patches, or miscellaneous
++feedback to me (Karl Garrison) at: kgarrison@pobox.com.  Note that as
++of this writing, I only have sporatic Internet access, so I may not get
++back to you right away.
++
++Happy Hacking!
++
++Karl Garrison
++March, 2009
++
++
+diff -burN nethack-3.4.3/win/curses/Todo.txt nethack/win/curses/Todo.txt
+--- nethack-3.4.3/win/curses/Todo.txt	1969-12-31 19:00:00.000000000 -0500
++++ nethack/win/curses/Todo.txt	2009-03-11 14:32:27.000000000 -0400
+@@ -0,0 +1,146 @@
++Below are some things I would like to see
++
++NETHACK INTERFACE
++=================
++
++(These are the functions in cursmain.c called by the core NetHack code)
++
++ * Implement curses_rip for optional fancier color tombstone, as well
++ as one that will display correctly on smaller terminals.
++ 
++ * I am confused as to how mark_synch, wait_synch, and delay_output
++ should work.  Help, please?
++ 
++ * Both PDCurses and Ncurses have mouse support, so the poskey function
++ could probably be implemented easily enough.
++ 
++ * raw_print is supposed to be able to work before the windowing system
++ has been initialized, as well as after, so I am unsure if curses
++ functions should be used here.  Maybe check to see if initscr() has
++ been called, and use curses functions if so, and call initscr() from
++ there is not?  Right now it is just a call to puts() with no support
++ for bold text.
++
++
++DISPLAY
++=======
++
++ * Consolidate refreshes of the display for smoother output.
++
++ * Horizontal scrollbar to show position for displays < 80 columns.
++ 
++ * Calls to getch() should probably be turned into wgetch() for the
++ appropriate window.  This causes q