]> granicus.if.org Git - nethack/commitdiff
extend the tty statue patch to tiles
authornhmall <mjnh@persona.ca>
Sun, 19 Apr 2015 17:31:59 +0000 (13:31 -0400)
committernhmall <mjnh@persona.ca>
Sun, 19 Apr 2015 17:31:59 +0000 (13:31 -0400)
 Changes to be committed:
modified:   doc/fixes35.0
modified:   win/share/gifread.c
modified:   win/share/monsters.txt
modified:   win/share/objects.txt
modified:   win/share/other.txt
modified:   win/share/tile2bmp.c
modified:   win/share/tilemap.c

The tty code already had the statue patch included, where
statues are represented by stone versions similar in
appearance to their monster likeness.

This extends it to tiles.

A new pass through the monsters.txt file is done
in tile2bmp to include new modified tiles to the output
file that are gray-scaled versions for mapping to the
NetHack statue glyphs.

doc/fixes35.0
win/share/gifread.c
win/share/monsters.txt
win/share/objects.txt
win/share/other.txt
win/share/tile2bmp.c
win/share/tilemap.c

index 36894c6979db5212130c83ceca6ba09129d0e06e..dea6543802f95d5c40da1d648b57d4c9113bee69 100644 (file)
@@ -1151,7 +1151,7 @@ tty,win32gui,win32tty: add menucolors
 NetHack Community Patches (or Variation) Included
 -------------------------------------------------
 Roderick Schertler's pickup_thrown patch
-Malcolm Ryan's Statue Glyphs patch
+adopt/adapt/extend Malcolm Ryan's Statue Glyphs patch to work for tty and tiles
 adopt/adapt/improve the Paranoid_Quit patch; default is paranoid_confirm:pray
        paranoid_confirm:Confirm when requiring "yes" instead of y to confirm,
                                 also require explicit "no" to reject
index 824393af9c3cbac6f93b35dc04f98e50561a2a41..8147c33806da533a05042cdaf1d115fb805aafd0 100644 (file)
@@ -13,7 +13,7 @@
 /* +-------------------------------------------------------------------+ */
 
 /*
- * $NHDT-Date$  $NHDT-Branch$:$NHDT-Revision$
+ * $NHDT-Date: 1429464661 2015/04/19 17:31:01 $  $NHDT-Branch: master $:$NHDT-Revision: 1.2 $
  * $Date: 2002/01/05 21:06:02 $  $Revision: 1.1 $
  */
 
@@ -71,7 +71,7 @@ static void FDECL(ReadTileStrip, (FILE *fd, int len));
 
 /* These should be in gif.h, but there isn't one. */
 boolean FDECL(fopen_gif_file, (const char *, const char *));
-boolean FDECL(read_gif_tile, (pixel(*)[]));
+boolean FDECL(read_gif_tile, (pixel(*)[TILE_X]));
 int NDECL(fclose_gif_file);
 
 static int
index 92aea0bf1d0857f7eecc6a2cfe37b3b54477e882..975ba1d7c093859a2dbc07104b7c5d0c215d0ed8 100644 (file)
@@ -12,8 +12,19 @@ K = (204, 79, 0)
 L = (255, 182, 145)
 M = (71, 108, 108)
 N = (255, 255, 255)
-O = (218, 218, 182)
+O = (215, 215, 215)
 P = (108, 145, 182)
+Q = (18, 18, 18)
+R = (54, 54, 54)
+S = (73, 73, 73)
+T = (82, 82, 82)
+U = (71, 108, 108)
+V = (104, 104, 104)
+W = (131, 131, 131)
+X = (140, 140, 140)
+Y = (149, 149, 149)
+Z = (195, 195, 195)
+
 # tile 0 (giant ant)
 {
   MMMMMMMMMMMMMMMM
index 7a1c5c7f68ebc78bcf0fb7dfd2bde72dfe42157c..7ee156c55f141813ecff7857c6737045d8f1cd83 100644 (file)
@@ -12,8 +12,19 @@ K = (204, 79, 0)
 L = (255, 182, 145)
 M = (71, 108, 108)
 N = (255, 255, 255)
-O = (218, 218, 182)
+O = (215, 215, 215)
 P = (108, 145, 182)
+Q = (18, 18, 18)
+R = (54, 54, 54)
+S = (73, 73, 73)
+T = (82, 82, 82)
+U = (71, 108, 108)
+V = (104, 104, 104)
+W = (131, 131, 131)
+X = (140, 140, 140)
+Y = (149, 149, 149)
+Z = (195, 195, 195)
+
 # tile 0 (strange object)
 {
   MMMMMMMMMMMMMMMM
index 292295085c192c62ded0454d90a4101815708e69..71132f522b157b0630716e72a856a3c95a072ca8 100644 (file)
@@ -12,8 +12,19 @@ K = (204, 79, 0)
 L = (255, 182, 145)
 M = (71, 108, 108)
 N = (255, 255, 255)
-O = (218, 218, 182)
+O = (215, 215, 215)
 P = (108, 145, 182)
+Q = (18, 18, 18)
+R = (54, 54, 54)
+S = (73, 73, 73)
+T = (82, 82, 82)
+U = (71, 108, 108)
+V = (104, 104, 104)
+W = (131, 131, 131)
+X = (140, 140, 140)
+Y = (149, 149, 149)
+Z = (195, 195, 195)
+
 # tile 0 (dark part of a room)
 {
   AAAAAAAAAAAAAAAA
index fde808967c84acc24aef7269d8a726127ac125e1..752720c8016f9a707221521ea739d8ace4b3a9e7 100644 (file)
@@ -1,6 +1,4 @@
-/* NetHack 3.5 tile2bmp.c      $NHDT-Date$  $NHDT-Branch$:$NHDT-Revision$ */
-/* NetHack 3.5 tile2bmp.c      $Date: 2009/05/06 10:59:00 $  $Revision: 1.6 $ */
-/*     SCCS Id: @(#)tile2bmp.c 3.5     2002/03/14      */
+/* NetHack 3.5 tile2bmp.c      $NHDT-Date: 1429464667 2015/04/19 17:31:07 $  $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
 /*   Copyright (c) NetHack PC Development Team 1995                 */
 /*   NetHack may be freely redistributed.  See license for details. */
 
@@ -8,6 +6,7 @@
  * Edit History:
  *
  *     Initial Creation                        M.Allison   1994/01/11
+ *     256 colour bmp and statue support       M.Allison   2015/04/19
  *
  */
 
 #include "win32api.h"
 #endif
 
-/* #define COLORS_IN_USE MAXCOLORMAPSIZE       /* 256 colors */
 #if (TILE_X==32)
 #define COLORS_IN_USE 256
 #else
-#define COLORS_IN_USE 16                       /* 16 colors */
+/*#define COLORS_IN_USE 16 */   /* 16 colors */
+#define COLORS_IN_USE 256      /* 256 colors */
 #endif
 
 #define BITCOUNT 8
 
 extern char *FDECL(tilename, (int, int));
 
+#define MAGICTILENO    (340 + 440 + 231 + 340)
+
 #if BITCOUNT==4
 #define MAX_X 320              /* 2 per byte, 4 bits per pixel */
 #define MAX_Y 480
 #else
 # if (TILE_X==32)
 #define MAX_X (32 * 40)
-#define MAX_Y 960
+#define MAX_Y ((MAGICTILENO * 32) / 40) * 2
 # else
-#define MAX_X 640              /* 1 per byte, 8 bits per pixel */
-#define MAX_Y 480
+#define MAX_X (16 * 40)
+#define MAX_Y ((MAGICTILENO * 16) / 40) * 2
 # endif
 #endif 
 
@@ -119,7 +120,8 @@ struct tagBMP{
 #if (TILE_X==32)
 #define RGBQUAD_COUNT 256
 #else
-#define RGBQUAD_COUNT 16
+/*#define RGBQUAD_COUNT 16 */
+#define RGBQUAD_COUNT 256
 #endif
     RGBQUAD          bmaColors[RGBQUAD_COUNT];
 #endif
@@ -146,11 +148,11 @@ char *tilefiles[] = {
 #if (TILE_X == 32)
                "../win/share/mon32.txt",
                "../win/share/obj32.txt",
-               "../win/share/oth32.txt"
+               "../win/share/oth32.txt",
 #else
                "../win/share/monsters.txt",
                "../win/share/objects.txt",
-               "../win/share/other.txt"
+               "../win/share/other.txt",
 #endif
 };
 
@@ -160,6 +162,7 @@ int max_tiles_in_row = 40;
 int tiles_in_row;
 int filenum;
 int initflag;
+int pass;
 int yoffset,xoffset;
 char bmpname[128];
 FILE *fp;
@@ -190,12 +193,14 @@ char *argv[];
        xoffset = yoffset = 0;
        initflag = 0;
        filenum = 0;
+       pass = 0;
        fp = fopen(bmpname,"wb");
        if (!fp) {
            printf("Error creating tile file %s, aborting.\n",bmpname);
            exit(1);
        }
-       while (filenum < (sizeof(tilefiles) / sizeof(char *))) {
+       while (pass < 4) {
+               filenum =pass % (sizeof(tilefiles) / sizeof(char *));
                if (!fopen_text_file(tilefiles[filenum], RDTMODE)) {
                        Fprintf(stderr,
                                "usage: tile2bmp (from the util directory)\n");
@@ -235,7 +240,7 @@ char *argv[];
                        }
                }
                (void) fclose_text_file();
-               ++filenum;
+               ++pass;
        }
        fwrite(&bmp, sizeof(bmp), 1, fp);
        fclose(fp);
@@ -303,18 +308,23 @@ BITMAPINFOHEADER *pbmih;
 #endif
 
 #if (TILE_X==16)
-       pbmih->biSizeImage = lelong(0);
+       /* pbmih->biSizeImage = lelong(0); */
+       pbmih->biSizeImage = lelong(((w * cClrBits +31) & ~31) /8 * h);
 #else
        pbmih->biSizeImage = lelong(((w * cClrBits +31) & ~31) /8 * h);
 #endif
        pbmih->biClrImportant = (DWORD)0;
 }
 
+static int graymappings[] = {
+      /*A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P*/
+       0, 16, 17, 18, 19, 12, 21, 22, 23, 24, 25, 14, 12, 13, 13, 13};
+
 static void
 build_bmptile(pixels)
 pixel (*pixels)[TILE_X];
 {
-       int cur_x, cur_y, cur_color;
+       int cur_x, cur_y, cur_color, apply_color;
        int x,y;
 
        for (cur_y = 0; cur_y < TILE_Y; cur_y++) {
@@ -328,6 +338,15 @@ pixel (*pixels)[TILE_X];
          if (cur_color >= num_colors)
                Fprintf(stderr, "color not in colormap!\n");
          y = (MAX_Y - 1) - (cur_y + yoffset);
+         apply_color = cur_color;
+         if (pass == 3) {
+               /* map to shades of gray */
+               if (cur_color > (SIZE(graymappings)-1))
+                       Fprintf(stderr, "Gray mapping issue %d %d.\n",
+                               cur_color, SIZE(graymappings)-1);
+               else
+                       apply_color = graymappings[cur_color];
+         }
 #if BITCOUNT==4
          x = (cur_x / 2) + xoffset;
          bmp.packtile[y][x] = cur_x%2 ?
@@ -335,7 +354,7 @@ pixel (*pixels)[TILE_X];
                (uchar)(cur_color<<4);
 #else
          x = cur_x + xoffset;
-         bmp.packtile[y][x] = (uchar)cur_color;
+         bmp.packtile[y][x] = (uchar)apply_color;
 #endif
         }
        }
index bb8273f47738b787bf68dc3aba74713168c39c5d..5e05a1888abb90892131dba3a83875f94465cd8e 100644 (file)
@@ -1,5 +1,4 @@
-/* NetHack 3.5 tilemap.c       $NHDT-Date: 1425082379 2015/02/28 00:12:59 $  $NHDT-Branch: master $:$NHDT-Revision: 1.12 $ */
-/* NetHack 3.5 tilemap.c       $Date: 2009/05/06 10:59:02 $  $Revision: 1.7 $ */
+/* NetHack 3.5 tilemap.c       $NHDT-Date: 1429464668 2015/04/19 17:31:08 $  $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
 /*     SCCS Id: @(#)tilemap.c  3.5     2000/06/04      */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -238,7 +237,7 @@ int set, entry;
 #endif
 
 short tilemap[MAX_GLYPH];
-int lastmontile, lastobjtile, lastothtile;
+int lastmontile, lastobjtile, lastothtile, laststatuetile;
 
 /* Number of tiles for invisible monsters */
 #define NUM_INVIS_TILES 1
@@ -357,13 +356,25 @@ init_tilemap()
                tilenum++;
        }
 
-       /* statue patch: statues still use the same glyph as in vanilla */
-        
-       for ( i = 0; i < NUMMONS; i++) {
-               tilemap[GLYPH_STATUE_OFF+i] = tilemap[GLYPH_OBJ_OFF+STATUE];
-        }        
-
        lastothtile = tilenum - 1;
+       
+       /* skip over the substitutes to get to the grayscale statues */
+       for (i = 0; i < SIZE(substitutes); i++) {
+          tilenum += substitutes[i].last_glyph - substitutes[i].first_glyph + 1;
+       }
+
+       /* statue patch: statues look more like the monster */
+       condnum = 0;                            /* doing monsters again, so reset */
+       for (i = 0; i < NUMMONS; i++) {
+               tilemap[GLYPH_STATUE_OFF+i] = tilenum;
+               tilenum++;
+               while (conditionals[condnum].sequence == MON_GLYPH &&
+                       conditionals[condnum].predecessor == i) {
+                       condnum++;
+                       tilenum++;
+               }
+       }
+       laststatuetile = tilenum - 1;
 }
 
 const char *prolog[] = {