Annotation of dgamelaunch-openbsd/stripgfx.c, Revision 1.1
1.1 ! rubenllo 1: /* Parts taken from drawing.c, nethack source */
! 2: /* Copyright (c) NetHack Development Team 1992. */
! 3: /* NetHack may be freely redistributed. See license for details. */
! 4:
! 5: #include <string.h>
! 6: #include "stripgfx.h"
! 7:
! 8: #define MAXPCHARS 92
! 9:
! 10: unsigned char gfx_map[256];
! 11: unsigned int state = 0;
! 12:
! 13: static unsigned char no_graphics[MAXPCHARS] = {
! 14: ' ', /* 0 */
! 15: /* stone */
! 16: '|', /* vwall */
! 17: '-', /* hwall */
! 18: '-', /* tlcorn */
! 19: '-', /* trcorn */
! 20: '-', /* blcorn */
! 21: '-', /* brcorn */
! 22: '-', /* crwall */
! 23: '-', /* tuwall */
! 24: '-', /* tdwall */
! 25: '|', /* 10 */
! 26: /* tlwall */
! 27: '|', /* trwall */
! 28: '.', /* ndoor */
! 29: '-', /* vodoor */
! 30: '|', /* hodoor */
! 31: '+', /* vcdoor */
! 32: '+', /* hcdoor */
! 33: '#', /* bars */
! 34: '#', /* tree */
! 35: '.', /* room */
! 36: '#', /* 20 */
! 37: /* dark corr */
! 38: '#', /* lit corr */
! 39: '<', /* upstair */
! 40: '>', /* dnstair */
! 41: '<', /* upladder */
! 42: '>', /* dnladder */
! 43: '_', /* altar */
! 44: '|', /* grave */
! 45: '\\', /* throne */
! 46: '#', /* sink */
! 47: '{', /* 30 */
! 48: /* fountain */
! 49: '}', /* pool */
! 50: '.', /* ice */
! 51: '}', /* lava */
! 52: '.', /* vodbridge */
! 53: '.', /* hodbridge */
! 54: '#', /* vcdbridge */
! 55: '#', /* hcdbridge */
! 56: ' ', /* open air */
! 57: '#', /* [part of] a cloud */
! 58: '}', /* 40 */
! 59: /* under water */
! 60: '^', /* trap */
! 61: '^', /* trap */
! 62: '^', /* trap */
! 63: '^', /* trap */
! 64: '^', /* trap */
! 65: '^', /* trap */
! 66: '^', /* trap */
! 67: '^', /* trap */
! 68: '^', /* trap */
! 69: '^', /* 50 */
! 70: /* trap */
! 71: '^', /* trap */
! 72: '^', /* trap */
! 73: '^', /* trap */
! 74: '^', /* trap */
! 75: '^', /* trap */
! 76: '^', /* trap */
! 77: '^', /* trap */
! 78: '"', /* web */
! 79: '^', /* trap */
! 80: '^', /* 60 */
! 81: /* trap */
! 82: '^', /* trap */
! 83: '^', /* trap */
! 84: '|', /* vbeam */
! 85: '-', /* hbeam */
! 86: '\\', /* lslant */
! 87: '/', /* rslant */
! 88: '*', /* dig beam */
! 89: '!', /* camera flash beam */
! 90: ')', /* boomerang open left */
! 91: '(', /* 70 */
! 92: /* boomerang open right */
! 93: '0', /* 4 magic shield symbols */
! 94: '#',
! 95: '@',
! 96: '*',
! 97: '/', /* swallow top left */
! 98: '-', /* swallow top center */
! 99: '\\', /* swallow top right */
! 100: '|', /* swallow middle left */
! 101: '|', /* swallow middle right */
! 102: '\\', /* 80 */
! 103: /* swallow bottom left */
! 104: '-', /* swallow bottom center */
! 105: '/', /* swallow bottom right */
! 106: '/', /* explosion top left */
! 107: '-', /* explosion top center */
! 108: '\\', /* explosion top right */
! 109: '|', /* explosion middle left */
! 110: ' ', /* explosion middle center */
! 111: '|', /* explosion middle right */
! 112: '\\', /* explosion bottom left */
! 113: '-', /* 90 */
! 114: /* explosion bottom center */
! 115: '/' /* explosion bottom right */
! 116: };
! 117:
! 118: static unsigned char ibm_graphics[MAXPCHARS] = {
! 119: /* 0*/ 0x00,
! 120: 0xb3, /* : meta-3, vertical rule */
! 121: 0xc4, /* : meta-D, horizontal rule */
! 122: 0xda, /* : meta-Z, top left corner */
! 123: 0xbf, /* : meta-?, top right corner */
! 124: 0xc0, /* : meta-@, bottom left */
! 125: 0xd9, /* : meta-Y, bottom right */
! 126: 0xc5, /* : meta-E, cross */
! 127: 0xc1, /* : meta-A, T up */
! 128: 0xc2, /* : meta-B, T down */
! 129: /*10 */ 0xb4,
! 130: /* : meta-4, T left */
! 131: 0xc3, /* : meta-C, T right */
! 132: 0xfa, /* : meta-z, centered dot */
! 133: 0xfe, /* : meta-~, small centered square */
! 134: 0xfe, /* : meta-~, small centered square */
! 135: 0x00,
! 136: 0x00,
! 137: 240, /* : equivalence symbol */
! 138: 241, /* : plus or minus symbol */
! 139: 0xfa, /* : meta-z, centered dot */
! 140: /*20 */ 0xb0,
! 141: /* : meta-0, light shading */
! 142: 0xb1, /* : meta-1, medium shading */
! 143: 0x00,
! 144: 0x00,
! 145: 0x00,
! 146: 0x00,
! 147: 0x00,
! 148: 0x00,
! 149: 0x00,
! 150: 0x00,
! 151: /*30 */ 0xf4,
! 152: /* : meta-t, integral top half */
! 153: 0xf7, /* : meta-w, approx. equals */
! 154: 0xfa, /* : meta-z, centered dot */
! 155: 0xf7, /* : meta-w, approx. equals */
! 156: 0xfa, /* : meta-z, centered dot */
! 157: 0xfa, /* : meta-z, centered dot */
! 158: 0x00,
! 159: 0x00,
! 160: 0x00,
! 161: 0x00,
! 162: /*40 */ 0xf7,
! 163: /* : meta-w, approx. equals */
! 164: 0x00,
! 165: 0x00,
! 166: 0x00,
! 167: 0x00,
! 168: 0x00,
! 169: 0x00,
! 170: 0x00,
! 171: 0x00,
! 172: 0x00,
! 173: /*50*/ 0x00,
! 174: 0x00,
! 175: 0x00,
! 176: 0x00,
! 177: 0x00,
! 178: 0x00,
! 179: 0x00,
! 180: 0x00,
! 181: 0x00,
! 182: 0x00,
! 183: /*60*/ 0x00,
! 184: 0x00,
! 185: 0x00,
! 186: 0xb3, /* : meta-3, vertical rule */
! 187: 0xc4, /* : meta-D, horizontal rule */
! 188: 0x00,
! 189: 0x00,
! 190: 0x00,
! 191: 0x00,
! 192: 0x00,
! 193: /*70*/ 0x00,
! 194: 0x00,
! 195: 0x00,
! 196: 0x00,
! 197: 0x00,
! 198: 0x00,
! 199: 0x00,
! 200: 0x00,
! 201: 0xb3, /* : meta-3, vertical rule */
! 202: 0xb3, /* : meta-3, vertical rule */
! 203: /*80*/ 0x00,
! 204: 0x00,
! 205: 0x00,
! 206: 0x00,
! 207: 0x00,
! 208: 0x00,
! 209: 0xb3, /* : meta-3, vertical rule */
! 210: 0x00,
! 211: 0xb3, /* : meta-3, vertical rule */
! 212: 0x00,
! 213: /*90*/ 0x00,
! 214: 0x00
! 215: };
! 216:
! 217: static unsigned char dec_graphics[MAXPCHARS] = {
! 218: /* 0*/ 0x00,
! 219: 0xf8, /* : meta-x, vertical rule */
! 220: 0xf1, /* : meta-q, horizontal rule */
! 221: 0xec, /* : meta-l, top left corner */
! 222: 0xeb, /* : meta-k, top right corner */
! 223: 0xed, /* : meta-m, bottom left */
! 224: 0xea, /* : meta-j, bottom right */
! 225: 0xee, /* : meta-n, cross */
! 226: 0xf6, /* : meta-v, T up */
! 227: 0xf7, /* : meta-w, T down */
! 228: /*10 */ 0xf5,
! 229: /* : meta-u, T left */
! 230: 0xf4, /* : meta-t, T right */
! 231: 0xfe, /* : meta-~, centered dot */
! 232: 0xe1, /* : meta-a, solid block */
! 233: 0xe1, /* : meta-a, solid block */
! 234: 0x00,
! 235: 0x00,
! 236: 0xfb, /* : meta-{, small pi */
! 237: 0xe7, /* : meta-g, plus-or-minus */
! 238: 0xfe, /* : meta-~, centered dot */
! 239: /*20*/ 0x00,
! 240: 0x00,
! 241: 0x00,
! 242: 0x00,
! 243: 0xf9, /* : meta-y, greater-than-or-equals */
! 244: 0xfa, /* : meta-z, less-than-or-equals */
! 245: 0x00, /* 0xc3, \E)3: meta-C, dagger */
! 246: 0x00,
! 247: 0x00,
! 248: 0x00,
! 249: /*30 */ 0x00,
! 250: /* 0xdb, \E)3: meta-[, integral top half */
! 251: 0xe0, /* : meta-\, diamond */
! 252: 0xfe, /* : meta-~, centered dot */
! 253: 0xe0, /* : meta-\, diamond */
! 254: 0xfe, /* : meta-~, centered dot */
! 255: 0xfe, /* : meta-~, centered dot */
! 256: 0x00,
! 257: 0x00,
! 258: 0x00,
! 259: 0x00,
! 260: /*40 */ 0xe0,
! 261: /* : meta-\, diamond */
! 262: 0x00,
! 263: 0x00,
! 264: 0x00,
! 265: 0x00,
! 266: 0x00,
! 267: 0x00,
! 268: 0x00,
! 269: 0x00,
! 270: 0x00,
! 271: /*50*/ 0x00,
! 272: 0x00,
! 273: 0x00,
! 274: 0x00,
! 275: 0x00,
! 276: 0x00,
! 277: 0x00,
! 278: 0x00,
! 279: 0x00, /* 0xbd, \E)3: meta-=, int'l currency */
! 280: 0x00,
! 281: /*60*/ 0x00,
! 282: 0x00,
! 283: 0x00,
! 284: 0xf8, /* : meta-x, vertical rule */
! 285: 0xf1, /* : meta-q, horizontal rule */
! 286: 0x00,
! 287: 0x00,
! 288: 0x00,
! 289: 0x00,
! 290: 0x00,
! 291: /*70*/ 0x00,
! 292: 0x00,
! 293: 0x00,
! 294: 0x00,
! 295: 0x00,
! 296: 0x00,
! 297: 0xef, /* : meta-o, high horizontal line */
! 298: 0x00,
! 299: 0xf8, /* : meta-x, vertical rule */
! 300: 0xf8, /* : meta-x, vertical rule */
! 301: /*80*/ 0x00,
! 302: 0xf3, /* : meta-s, low horizontal line */
! 303: 0x00,
! 304: 0x00,
! 305: 0xef, /* : meta-o, high horizontal line */
! 306: 0x00,
! 307: 0xf8, /* : meta-x, vertical rule */
! 308: 0x00,
! 309: 0xf8, /* : meta-x, vertical rule */
! 310: 0x00,
! 311: /*90 */ 0xf3,
! 312: /* : meta-s, low horizontal line */
! 313: 0x00
! 314: };
! 315:
! 316: static unsigned char IBM_r_oc_syms[18] = { /* a la EPYX Rogue */
! 317: /* 0*/ '\0',
! 318: 0x00,
! 319: 0x18, /* weapon: up arrow */
! 320: /* 0x0a, */ 0x00,
! 321: /* armor: Vert rect with o */
! 322: /* 0x09, */ 0x00,
! 323: /* ring: circle with arrow */
! 324: /* 5 */ 0x0c,
! 325: /* amulet: "female" symbol */
! 326: 0x00,
! 327: 0x05, /* food: club (as in cards) */
! 328: 0xad, /* potion: upside down '!' */
! 329: 0x0e, /* scroll: musical note */
! 330: /*10*/ 0x00,
! 331: 0xe7, /* wand: greek tau */
! 332: 0x0f, /* gold: yes it's the same as gems */
! 333: 0x0f, /* gems: fancy '*' */
! 334: 0x00,
! 335: /*15*/ 0x00,
! 336: 0x00,
! 337: 0x00
! 338: };
! 339:
! 340: void
! 341: populate_gfx_array (int gfxset)
! 342: {
! 343: int i;
! 344:
! 345: state = 0;
! 346:
! 347: memset (gfx_map, 0, 256);
! 348:
! 349: if (gfxset == NO_GRAPHICS)
! 350: return;
! 351:
! 352: for (i = 0; i < MAXPCHARS; i++)
! 353: {
! 354: if ((gfxset == DEC_GRAPHICS) && (dec_graphics[i])
! 355: && !(gfx_map[dec_graphics[i]]))
! 356: gfx_map[dec_graphics[i] - 128] = no_graphics[i];
! 357: if ((gfxset == IBM_GRAPHICS) && (ibm_graphics[i]))
! 358: gfx_map[ibm_graphics[i]] = no_graphics[i];
! 359: }
! 360:
! 361: if (gfxset == IBM_GRAPHICS)
! 362: state = -1;
! 363:
! 364: /*
! 365: endwin();
! 366: for (i=0;i<256;i++) {
! 367: printf("%X:%X ",i,gfx_map[i]);
! 368: }
! 369: exit(1); */
! 370: }
! 371:
! 372: unsigned char
! 373: strip_gfx (unsigned char inchar)
! 374: {
! 375: if ((inchar == 0x0E) && (state == 0))
! 376: {
! 377: state = 1;
! 378: return 0x00;
! 379: }
! 380:
! 381: if ((inchar == 0x0F) && (state == 1))
! 382: {
! 383: state = 0;
! 384: return inchar;
! 385: }
! 386:
! 387: if ((inchar == 0x1B) && (state == 1))
! 388: {
! 389: state = 0;
! 390: return inchar;
! 391: }
! 392:
! 393: if (gfx_map[inchar] && (state == 1 || state == -1))
! 394: {
! 395: return gfx_map[inchar];
! 396: }
! 397:
! 398: return inchar;
! 399: }
CVSweb