diff -Naur tome-231-src/src/cave.c tome-231-src/src/cave.c --- tome-231-src/src/cave.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/cave.c 2005-04-07 04:46:48.000000000 -0700 @@ -393,7 +393,7 @@ /* * Mega-Hack -- Hallucinatory monster */ -static void image_monster(byte *ap, char *cp) +static void image_monster(byte *ap, glyf *cp) { int n; @@ -444,7 +444,7 @@ /* * Mega-Hack -- Hallucinatory object */ -static void image_object(byte *ap, char *cp) +static void image_object(byte *ap, glyf *cp) { int n; @@ -482,7 +482,7 @@ /* * Hack -- Random hallucination */ -static void image_random(byte *ap, char *cp) +static void image_random(byte *ap, glyf *cp) { /* Normally, assume monsters */ if (rand_int(100) < 75) @@ -868,13 +868,13 @@ #ifdef USE_TRANSPARENCY #ifdef USE_EGO_GRAPHICS -void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp, - byte *eap, char *ecp) +void map_info(int y, int x, byte *ap, glyf *cp, byte *tap, glyf *tcp, + byte *eap, glyf *ecp) #else /* USE_EGO_GRAPHICS */ -void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp) +void map_info(int y, int x, byte *ap, glyf *cp, byte *tap, glyf *tcp) #endif /* USE_EGO_GRAPHICS */ #else /* USE_TRANSPARENCY */ -void map_info(int y, int x, byte *ap, char *cp) +void map_info(int y, int x, byte *ap, glyf *cp) #endif /* USE_TRANSPARENCY */ { cave_type *c_ptr; @@ -891,7 +891,7 @@ byte a; - byte c; + glyf c; /* * This means that a port supports graphics overlay as well as lighting @@ -1573,7 +1573,7 @@ * Special version of map_info, for use by cmovie and HTML converter * to obtain pure-ASCII image of dungeon map */ -void map_info_default(int y, int x, byte *ap, char *cp) +void map_info_default(int y, int x, byte *ap, glyf *cp) { cave_type *c_ptr; @@ -1589,7 +1589,7 @@ byte a; - byte c; + glyf c; bool use_graphics_hack = use_graphics; byte graphics_mode_hack = graphics_mode; @@ -2049,7 +2049,7 @@ /* * Place an attr/char pair at the given map coordinate, if legal. */ -void print_rel(char c, byte a, int y, int x) +void print_rel(glyf c, byte a, int y, int x) { /* Paranoia -- Only do "legal" locations */ if (!panel_contains(y, x)) return; @@ -2192,15 +2192,15 @@ void lite_spot(int y, int x) { byte a, a2; - byte c, c2; + glyf c, c2; #ifdef USE_TRANSPARENCY byte ta; - char tc; + glyf tc; # ifdef USE_EGO_GRAPHICS byte ea; - char ec; + glyf ec; # endif /* USE_EGO_GRAPHICS */ #endif /* USE_TRANSPARENCY */ @@ -2260,7 +2260,7 @@ #else /* USE_TRANSPARENCY */ /* Examine the grid */ - map_info(y, x, &a, (char *) &c); + map_info(y, x, &a, (glyf *) &c); /* Hack -- Queue it */ Term_queue_char(panel_col_of(x), y - panel_row_prt, a, c); @@ -2313,15 +2313,15 @@ for (x = panel_col_min; x <= panel_col_max; x++) { byte a, a2; - char c, c2; + glyf c, c2; #ifdef USE_TRANSPARENCY byte ta; - char tc; + glyf tc; #ifdef USE_EGO_GRAPHICS byte ea; - char ec; + glyf ec; /* Determine what is there */ map_info(y, x, &a, &c, &ta, &tc, &ea, &ec); @@ -2487,7 +2487,7 @@ /* * Hack -- a priority function (see below) */ -static byte priority(byte a, char c) +static byte priority(byte a, glyf c) { int i, p0, p1; @@ -2535,12 +2535,12 @@ int i, j, x, y; byte ta; - char tc; + glyf tc; byte tp; byte **ma; - char **mc; + glyf **mc; byte **mp; @@ -2584,14 +2584,14 @@ /* Allocate temporary memory for the maps */ C_MAKE(ma, hgt + 2, byte *); - C_MAKE(mc, hgt + 2, char *); + C_MAKE(mc, hgt + 2, glyf *); C_MAKE(mp, hgt + 2, byte *); /* Allocate each line in the maps */ for (i = 0; i < hgt + 2; i++) { C_MAKE(ma[i], wid + 2, byte); - C_MAKE(mc[i], wid + 2, char); + C_MAKE(mc[i], wid + 2, glyf); C_MAKE(mp[i], wid + 2, byte); } @@ -2691,7 +2691,7 @@ if (use_bigtile) { byte a2; - char c2; + glyf c2; if (ta & 0x80) { @@ -2725,13 +2725,13 @@ for (i = 0; i < hgt + 2; i++) { C_FREE(ma[i], wid + 2, byte); - C_FREE(mc[i], wid + 2, char); + C_FREE(mc[i], wid + 2, glyf); C_FREE(mp[i], wid + 2, byte); } /* Allocate temporary memory for the maps */ C_FREE(ma, hgt + 2, byte *); - C_FREE(mc, hgt + 2, char *); + C_FREE(mc, hgt + 2, glyf *); C_FREE(mp, hgt + 2, byte *); diff -Naur tome-231-src/src/cmd2.c tome-231-src/src/cmd2.c --- tome-231-src/src/cmd2.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/cmd2.c 2005-04-07 04:47:04.000000000 -0700 @@ -3133,7 +3133,7 @@ byte missile_attr; - char missile_char; + glyf missile_char; char o_name[80]; @@ -3618,7 +3618,7 @@ byte missile_attr; - char missile_char; + glyf missile_char; char o_name[80]; @@ -4013,7 +4013,7 @@ byte missile_attr; - char missile_char; + glyf missile_char; char o_name[80]; diff -Naur tome-231-src/src/cmd3.c tome-231-src/src/cmd3.c --- tome-231-src/src/cmd3.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/cmd3.c 2005-04-07 04:47:10.000000000 -0700 @@ -1557,7 +1557,8 @@ byte a1, a2; - char c1, c2; + char c1; + glyf c2; /* Access the chars */ @@ -1614,6 +1615,9 @@ * The responses may be sorted in several ways, see below. * * Note that the player ghosts are ignored. XXX XXX XXX + * TODO: figure out how this works in unicode: classes of monsters + * should retain their original type, such as unique orcs -> o + * maybe allow for copy-paste? */ void do_cmd_query_symbol(void) { diff -Naur tome-231-src/src/cmd4.c tome-231-src/src/cmd4.c --- tome-231-src/src/cmd4.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/cmd4.c 2005-04-07 04:47:19.000000000 -0700 @@ -2230,7 +2230,7 @@ /* Dump the monster attr/char info */ fprintf(fff, "R:%d:0x%02X:0x%02X\n\n", i, - (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char)); + (byte)(r_ptr->x_attr), (u16b)(r_ptr->x_char)); } /* All done */ @@ -2284,7 +2284,7 @@ /* Dump the object attr/char info */ fprintf(fff, "K:%d:0x%02X:0x%02X\n\n", i, - (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char)); + (byte)(k_ptr->x_attr), (u16b)(k_ptr->x_char)); } /* All done */ @@ -2338,7 +2338,7 @@ /* Dump the feature attr/char info */ fprintf(fff, "F:%d:0x%02X:0x%02X\n\n", i, - (byte)(f_ptr->x_attr), (byte)(f_ptr->x_char)); + (byte)(f_ptr->x_attr), (u16b)(f_ptr->x_char)); } /* All done */ @@ -2367,7 +2367,7 @@ byte da = (r_ptr->d_attr); char dc = (r_ptr->d_char); byte ca = (r_ptr->x_attr); - char cc = (r_ptr->x_char); + glyf cc = r_ptr->x_char; /* Label the object */ Term_putstr(5, 17, -1, TERM_WHITE, @@ -2415,8 +2415,8 @@ if (i == 'N') r = (r + max_r_idx - 1) % max_r_idx; if (i == 'a') r_ptr->x_attr = (byte)(ca + 1); if (i == 'A') r_ptr->x_attr = (byte)(ca - 1); - if (i == 'c') r_ptr->x_char = (byte)(cc + 1); - if (i == 'C') r_ptr->x_char = (byte)(cc - 1); + if (i == 'c') r_ptr->x_char = cc + 1; + if (i == 'C') r_ptr->x_char = cc - 1; } } @@ -2436,7 +2436,7 @@ byte da = (byte)k_ptr->d_attr; char dc = (byte)k_ptr->d_char; byte ca = (byte)k_ptr->x_attr; - char cc = (byte)k_ptr->x_char; + glyf cc = k_ptr->x_char; /* Label the object */ Term_putstr(5, 17, -1, TERM_WHITE, @@ -2484,8 +2484,8 @@ if (i == 'N') k = (k + max_k_idx - 1) % max_k_idx; if (i == 'a') k_info[k].x_attr = (byte)(ca + 1); if (i == 'A') k_info[k].x_attr = (byte)(ca - 1); - if (i == 'c') k_info[k].x_char = (byte)(cc + 1); - if (i == 'C') k_info[k].x_char = (byte)(cc - 1); + if (i == 'c') k_info[k].x_char = cc + 1; + if (i == 'C') k_info[k].x_char = cc - 1; } } @@ -2505,7 +2505,7 @@ byte da = (byte)f_ptr->d_attr; char dc = (byte)f_ptr->d_char; byte ca = (byte)f_ptr->x_attr; - char cc = (byte)f_ptr->x_char; + glyf cc = f_ptr->x_char; /* Label the object */ Term_putstr(5, 17, -1, TERM_WHITE, @@ -2553,8 +2553,8 @@ if (i == 'N') f = (f + max_f_idx - 1) % max_f_idx; if (i == 'a') f_info[f].x_attr = (byte)(ca + 1); if (i == 'A') f_info[f].x_attr = (byte)(ca - 1); - if (i == 'c') f_info[f].x_char = (byte)(cc + 1); - if (i == 'C') f_info[f].x_char = (byte)(cc - 1); + if (i == 'c') f_info[f].x_char = cc + 1; + if (i == 'C') f_info[f].x_char = cc - 1; if (i == 'd') { f_info[f].x_char = f_ptr->d_char; @@ -3045,7 +3045,7 @@ int len; byte a = 0; - char c = ' '; + glyf c = ' '; bool okay = TRUE; @@ -3190,7 +3190,7 @@ int wid, hgt; byte a = 0; - char c = ' '; + glyf c = ' '; FILE *fff; diff -Naur tome-231-src/src/cmovie.c tome-231-src/src/cmovie.c --- tome-231-src/src/cmovie.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/cmovie.c 2005-04-07 04:47:33.000000000 -0700 @@ -423,10 +423,10 @@ void cmovie_clean_line(int y, char *abuf, char *cbuf) { const byte *ap = Term->scr->a[y]; - const char *cp = Term->scr->c[y]; + const glyf *cp = Term->scr->c[y]; byte a; - char c; + glyf c; int x; int wid, hgt; diff -Naur tome-231-src/src/config.h tome-231-src/src/config.h --- tome-231-src/src/config.h 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/config.h 2005-03-23 20:26:26.000000000 -0800 @@ -330,6 +330,12 @@ */ #define USE_GRAPHICS +/* + * OPTION: Allow the use of "glyphs" to represent objects + */ +#define USE_GLYPHS + + /* * OPTION: Hack -- Macintosh stuff diff -Naur tome-231-src/src/externs.h tome-231-src/src/externs.h --- tome-231-src/src/externs.h 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/externs.h 2005-04-07 04:48:57.000000000 -0700 @@ -645,16 +645,16 @@ extern bool no_lite(void); #ifdef USE_TRANSPARENCY #ifdef USE_EGO_GRAPHICS -extern void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp, byte *eap, char *ecp); +extern void map_info(int y, int x, byte *ap, glyf *cp, byte *tap, glyf *tcp, byte *eap, glyf *ecp); #else /* USE_EGO_GRAPHICS */ -extern void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp); +extern void map_info(int y, int x, byte *ap, glyf *cp, byte *tap, glyf *tcp); #endif /* USE_EGO_GRAPHICS */ #else /* USE_TRANSPARENCY */ -extern void map_info(int y, int x, byte *ap, char *cp); +extern void map_info(int y, int x, byte *ap, glyf *cp); #endif /* USE_TRANSPARENCY */ -extern void map_info_default(int y, int x, byte *ap, char *cp); +extern void map_info_default(int y, int x, byte *ap, glyf *cp); extern void move_cursor_relative(int row, int col); -extern void print_rel(char c, byte a, int y, int x); +extern void print_rel(glyf c, byte a, int y, int x); extern void note_spot(int y, int x); extern void lite_spot(int y, int x); extern void prt_map(void); @@ -1524,6 +1524,7 @@ extern char msg_box(cptr text, int y, int x); extern timer_type *new_timer(cptr callback, s32b delay); extern void del_timer(timer_type *t_ptr); +extern int glyf_ary_to_utf8(const glyf *a, int n, char *s); /* main.c */ #ifdef PRIVATE_USER_PATH diff -Naur tome-231-src/src/files.c tome-231-src/src/files.c --- tome-231-src/src/files.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/files.c 2005-04-07 04:47:47.000000000 -0700 @@ -2897,7 +2897,7 @@ static cptr blank_line = " "; static char buf[1024]; byte a; - char c; + glyf c; int x, y; y = show_legend ? 3 : 4; @@ -3030,7 +3030,7 @@ { int i, j, x, y; byte a; - char c; + glyf c; int fd = -1; FILE *fff = NULL; char buf[1024]; diff -Naur tome-231-src/src/h-type.h tome-231-src/src/h-type.h --- tome-231-src/src/h-type.h 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/h-type.h 2005-04-07 04:45:41.000000000 -0700 @@ -126,6 +126,9 @@ typedef unsigned long u32b; #endif +/* A visual glyph (e.g. '@') as char, unicode or graphic ID */ +typedef u16b glyf; + /*** Pointers to all the basic types defined above ***/ @@ -144,6 +147,7 @@ typedef u32b *u32b_ptr; typedef vptr *vptr_ptr; typedef cptr *cptr_ptr; +typedef glyf *glyf_ptr; diff -Naur tome-231-src/src/loadsave.c tome-231-src/src/loadsave.c --- tome-231-src/src/loadsave.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/loadsave.c 2005-03-23 00:07:25.000000000 -0800 @@ -2169,7 +2169,7 @@ do_byte(&m_ptr->sr_ptr->d_char, flag); do_byte(&m_ptr->sr_ptr->d_attr, flag); - do_byte(&m_ptr->sr_ptr->x_char, flag); + do_u16b(&m_ptr->sr_ptr->x_char, flag); do_byte(&m_ptr->sr_ptr->x_attr, flag); do_s16b(&m_ptr->sr_ptr->max_num, flag); diff -Naur tome-231-src/src/main-gtk2.c tome-231-src/src/main-gtk2.c --- tome-231-src/src/main-gtk2.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/main-gtk2.c 2005-04-07 06:23:07.000000000 -0700 @@ -28,6 +28,9 @@ * USE_GRAPHICS code bloat (^ ^;), added comments (I have * a strange habit of writing comments while I code...) * and reorganised the file a bit. + * + * Leon Torres worked in Pango support to take advantage of the latest + * GTK2.0+ developments. TODO: port to Angband. */ #include "angband.h" @@ -156,6 +159,27 @@ #endif /* USE_GRAPHICS */ +//#define DEFAULT_GTK2_FONT "Courier 12" +//#define DEFAULT_GTK2_FONT "Bitstream Vera Sans Mono 14" +#define DEFAULT_GTK2_FONT "Angband Mono 16" + +/* + * Container to store pango information (see Term_text_gtk and load_font) + */ +typedef struct pango_info pango_info; + +struct pango_info +{ + PangoContext *context; + PangoFontMetrics *metrics; + PangoFontDescription *font_desc; + PangoFont *font; + PangoLanguage *language; + PangoAnalysis *analysis; + int ascent; + int descent; +}; + /* * This structure holds everything you need to manipulate terminals @@ -169,8 +193,8 @@ GtkWidget *window; GtkWidget *drawing_area; GdkPixmap *backing_store; - GdkFont *font; - GdkGC *gc; + pango_info *pango; + GdkGC *gc; bool shown; byte last_attr; @@ -252,6 +276,7 @@ */ static term_data data[MAX_TERM_DATA]; + /* * Number of active terms */ @@ -288,6 +313,17 @@ /* * Look up some environment variables to find font name for each window. + * + * For pango, the font must be described as, + * + * "[family-list] [style-options] [size]" + * + * sans the brackets. Family-list is a comma separated list of families + * optionally terminated by a comma, style-options is a whitespace separated + * list of words where each word describes one of style, variant, weight + * or stretch, and size is a decimal number corresponding to the font size + * in points. Any of these options may be absent. For instance, + * "Courier New Bold 16" */ static cptr get_default_font(int term) { @@ -310,7 +346,7 @@ if (!font_name) font_name = getenv("ANGBAND_X11_FONT"); /* No environment variables, use default font */ - if (!font_name) font_name = DEFAULT_X11_FONT_SCREEN; + if (!font_name) font_name = DEFAULT_GTK2_FONT; return (font_name); } @@ -605,48 +641,6 @@ */ static cptr ANGBAND_DIR_XTRA_GRAF; - -/* - * Be nice to old graphics hardwares -- using GdkRGB. - * - * We don't have colour allocation failure any longer this way, - * even with 8bpp X servers. Gimp *does* work with 8bpp, why not Angband? - * - * Initialisation (before any widgets are created) - * gdk_rgb_init(); - * gtk_widget_set_default_colormap (gdk_rgb_get_cmap()); - * gtk_widget_set_default_visual (gdk_rgb_get_visual()); - * - * Setting fg/bg colours - * void gdk_rgb_gc_set_foreground(GdkGC *gc, guint32 rgb); - * void gdk_rgb_gc_set_background(GdkGC *gc, guint32 rgb); - * where rgb is 0xRRGGBB. - * - * Drawing rgb images - * void gdk_draw_rgb_image( - * GdkDrawable *drawable, - * GdkGC *gc, - * gint x, gint y, - * gint width, gint height, - * GdkRgbDither dith, - * guchar *rgb_buf, - * gint rowstride); - * - * dith: - * GDK_RGB_DITHER_NORMAL : dither if 8bpp or below - * GDK_RGB_DITHER_MAX : dither if 16bpp or below. - * - * for 0 <= i < width and 0 <= j < height, - * the pixel (x + i, y + j) is colored with - * red value rgb_buf[j * rowstride + i * 3], - * green value rgb_buf[j * rowstride + i * 3 + 1], and - * blue value rgb_buf[j * rowstride + i * 3 + 2]. - */ - -/* - * gdk_image compatibility functions - should be part of gdk, IMHO. - */ - /* * Create GdkRGBImage of width * height and return pointer * to it. Returns NULL on failure @@ -2469,7 +2463,7 @@ /* - * Free data used by a term + * Free data used by a term */ static void Term_nuke_gtk(term *t) { @@ -2482,11 +2476,15 @@ /* Forget it */ td->name = NULL; - /* Free font */ - if (td->font) gdk_font_unref(td->font); + /* Free pango info */ + if (td->pango != NULL) + { + /* Free analysis first */ + if (td->pango->analysis != NULL) + g_free(td->pango->analysis); - /* Forget it */ - td->font = NULL; + g_free(td->pango); + } /* Free backing store */ if (td->backing_store) gdk_pixmap_unref(td->backing_store); @@ -2582,8 +2580,35 @@ /* * Draw some textual characters. + * + * Pango update: Leon Torres + * + * This file has been updated to use the pango glyph rendering system. + * Since documentation for pango is sparse, I will describe how it works + * here for future reference. + * + * Pango is an abstraction layer glyph rendering system for GTK 2.0 and + * beyond. It handles unicode text transparently and is used by the GTK + * as the default rendering system. It renders the best glyph for a given + * unicode character using a set of fonts. It also has advanced layout + * capabilities to support internationalized text. + * + * Naturally, all of these capabilities make Pango an akward choice for + * fast rendering of monospace text. To resolve this issue, we will + * handle glyph rendering ourselves rather than leave it to the toolkits. + * + * Creating a glyph string involves itemizing some text using pango_itemize. + * This function inspects each character and assigns an appropriate set + * of rendering information called a PangoAnalysis. The analysis will have + * the same layout info for all monospace characters, so we create our own + * static one using some reference glyphs and use it for all text. We then + * create the glyph strings ourselves and use gdk_draw_glyphs to draw them. + * + * TODO: Rendering is still painfully slow, although it's much better than + * leaving it to Pango. Think about other optimizations. In particular, check + * hot the gnome terminal does it. */ -static errr Term_text_gtk(int x, int y, int n, byte a, cptr s) +static errr Term_text_gtk(int x, int y, int n, byte a, const glyf *s) { term_data *td = (term_data*)(Term->data); @@ -2600,15 +2625,26 @@ /* Clear the line */ Term_wipe_gtk(x, y, n); + char u[3*n+1]; + int n2 = glyf_ary_to_utf8(s, n, u); + + /* Allocate a glyph string */ + PangoGlyphString *glyph_string = pango_glyph_string_new(); + + /* Create the glyph string */ + pango_shape(u, n2, td->pango->analysis, glyph_string); + /* Draw the text to the window */ - gdk_draw_text( + gdk_draw_glyphs( TERM_DATA_DRAWABLE(td), - td->font, td->gc, + td->pango->font, x * td->font_wid, - td->font->ascent + y * td->font_hgt, - s, - n); + td->pango->ascent + y * td->font_hgt, + glyph_string); + + /* Free the glyphs */ + pango_glyph_string_free(glyph_string); /* Copy image from backing store if present */ TERM_DATA_REFRESH(td, x, y, n, 1); @@ -2773,19 +2809,19 @@ # ifdef USE_EGO_GRAPHICS static errr Term_pict_gtk( int x, int y, int n, - const byte *ap, const char *cp, - const byte *tap, const char *tcp, - const byte *eap, const char *ecp) + const byte *ap, const glyf *cp, + const byte *tap, const glyf *tcp, + const byte *eap, const glyf *ecp) # else /* USE_EGO_GRAPHICS */ static errr Term_pict_gtk( int x, int y, int n, - const byte *ap, const char *cp, - const byte *tap, const char *tcp) + const byte *ap, const glyf *cp, + const byte *tap, const glyf *tcp) # endif /* USE_EGO_GRAPHICS */ # else /* USE_TRANSPARENCY */ static errr Term_pict_gtk( int x, int y, int n, - const byte *ap, const char *cp) + const byte *ap, const glyf *cp) # endif /* USE_TRANSPARENCY */ { term_data *td = (term_data*)(Term->data); @@ -2824,19 +2860,19 @@ for (i = 0; i < n; i++) { byte a; - char c; + glyf c; int s_x, s_y; # ifdef USE_TRANSPARENCY byte ta; - char tc; + glyf tc; int t_x, t_y; # ifdef USE_EGO_GRAPHICS byte ea; - char ec; + glyf ec; int e_x = 0, e_y = 0; bool has_overlay; @@ -3443,7 +3479,7 @@ gpointer user_data) { /* This allows for cheating, but... */ - quit(NULL); + quit(NULL); } @@ -3494,30 +3530,33 @@ /* - * Load fond specified by an XLFD fontname and - * set up related term_data members + * Determines the size of the font glyphs. */ -static void load_font(term_data *td, cptr fontname) +static void init_font_metrics(term_data *td, cptr fontname) { - GdkFont *old = td->font; - - /* Load font */ - td->font = gdk_font_load(fontname); - - if (td->font) - { - /* Free the old font */ - if (old) gdk_font_unref(old); - } - else - { - /* Oops, but we can still use the old one */ - td->font = old; - } - /* Calculate the size of the font XXX */ - td->font_wid = gdk_char_width(td->font, '@'); - td->font_hgt = td->font->ascent + td->font->descent; + /* determine font metrics */ + td->pango->metrics = pango_font_get_metrics( + td->pango->font, td->pango->language); + + /* + * Calculate the font size. + * + * Ascent is the distance from the font baseline to the logical top + * of a line of text. Descent is the distance from the baseline to + * the logical bottom of a line of text. Hence, the sum of these two + * is the effective character height for a monospaced font. + * + * The Pango ascent is stored as 1024 * point size. + */ + int ascent = pango_font_metrics_get_ascent(td->pango->metrics); + int descent = pango_font_metrics_get_descent(td->pango->metrics); + int width = pango_font_metrics_get_approximate_digit_width(td->pango->metrics); + + td->pango->ascent = PANGO_PIXELS(ascent); + td->pango->descent = PANGO_PIXELS(descent); + td->font_hgt = td->pango->ascent + td->pango->descent; + td->font_wid = PANGO_PIXELS(width); #ifndef USE_DOUBLE_TILES @@ -3535,58 +3574,62 @@ #endif /* !USE_DOUBLE_TILES */ } - /* - * React to OK button press in font selection dialogue + * Initialize Pango info and loads a font for each term_data. */ -static void font_ok_callback( - GtkWidget *widget, - GtkWidget *font_selector) +static void load_font(term_data *td, cptr fontname) { - gchar *fontname; - term_data *td; - - td = gtk_object_get_data(GTK_OBJECT(font_selector), "term_data"); - - g_assert(td != NULL); - - /* Retrieve font name from player's selection */ - fontname = gtk_font_selection_dialog_get_font_name( - GTK_FONT_SELECTION_DIALOG(font_selector)); - - /* Leave unless selection was valid */ - if (fontname == NULL) return; - - /* Load font and update font size info */ - load_font(td, fontname); - - /* Hack - Hide the window - finally found the trick... */ - gtk_widget_hide_all(td->window); - - /* Resizes the drawing area */ - gtk_drawing_area_size( - GTK_DRAWING_AREA(td->drawing_area), - td->cols * td->font_wid, - td->rows * td->font_hgt); + if (td->pango == NULL) + td->pango = (pango_info *)g_malloc(sizeof(pango_info)); - /* Update the geometry hints for the window */ - term_data_set_geometry_hints(td); - - /* Reallocate the backing store */ - term_data_set_backing_store(td); - - /* Hack - Show the window */ - gtk_widget_show_all(td->window); - -#ifdef USE_GRAPHICS + /* Create a font description */ + td->pango->font_desc = pango_font_description_from_string(fontname); - /* We have to resize tiles when we are in graphics mode */ - resize_request = TRUE; + /* Give it to the widget */ + gtk_widget_modify_font(td->window, td->pango->font_desc); -#endif /* USE_GRAPHICS */ + /* Grab pango context and store */ + td->pango->context = gtk_widget_get_pango_context(td->window); + + /* Get the language too */ + td->pango->language = pango_context_get_language(td->pango->context); + + /* Load the best font */ + td->pango->font = pango_context_load_font( + td->pango->context, + td->pango->font_desc); + + /* + * Store our own analysis + */ + PangoAnalysis *analysis = (PangoAnalysis*)g_malloc(sizeof(PangoAnalysis)); + + /* Empty attributes for the itemizer */ + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttrIterator *aiter = pango_attr_list_get_iterator(attrs); + + /* Itemize a reference character */ + GList *items = pango_itemize(td->pango->context, "@", 0, 1, attrs, aiter); + + /* Grab the item from the list */ + PangoItem *item = (PangoItem*)items->data; + + /* Copy the analysis data */ + analysis->shape_engine = item->analysis.shape_engine; + analysis->lang_engine = item->analysis.lang_engine; + analysis->font = td->pango->font; + analysis->level = item->analysis.level; + analysis->language = item->analysis.language; + analysis->extra_attrs = NULL; + + /* Store it */ + td->pango->analysis = analysis; + + /* Free some stuff */ + pango_item_free(item); + g_list_free(items); - /* Hack - force redraw */ - Term_key_push(KTRL('R')); + init_font_metrics(td, fontname); } @@ -3599,51 +3642,67 @@ { GtkWidget *font_selector; - gchar *spacings[] = { "c", "m", NULL }; + /* XXX Can't seem to get gtk2 font selector to filter only mono! */ + //gchar *spacings[] = { "c", "m", NULL }; font_selector = gtk_font_selection_dialog_new("Select font"); -#if 0 // DGDGDGDG - gtk_object_set_data( - GTK_OBJECT(font_selector), - "term_data", - user_data); - - /* Filter to show only fixed-width fonts */ - gtk_font_selection_dialog_set_filter( - GTK_FONT_SELECTION_DIALOG(font_selector), - GTK_FONT_FILTER_BASE, - GTK_FONT_ALL, - NULL, - NULL, - NULL, - NULL, - spacings, - NULL); - gtk_signal_connect( - GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_selector)->ok_button), - "clicked", - font_ok_callback, - (gpointer)font_selector); + if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(font_selector))) + { + gtk_widget_destroy(font_selector); + return; + } + + gchar *fontname; + term_data *td; + + td = (term_data *)user_data; + + g_assert(td != NULL); + + /* Retrieve font name from player's selection */ + fontname = gtk_font_selection_dialog_get_font_name( + GTK_FONT_SELECTION_DIALOG(font_selector)); + + /* Leave unless selection was valid */ + if (fontname == NULL) + { + gtk_widget_destroy(font_selector); + return; + } + + /* Load font and update font size info */ + load_font(td, fontname); + + /* Hack - Hide the window - finally found the trick... */ + gtk_widget_hide_all(td->window); + + /* Resizes the drawing area */ + gtk_drawing_area_size( + GTK_DRAWING_AREA(td->drawing_area), + td->cols * td->font_wid, + td->rows * td->font_hgt); - /* - * Ensure that the dialog box is destroyed when the user clicks - * a button. - */ - gtk_signal_connect_object( - GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_selector)->ok_button), - "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), - (gpointer)font_selector); + /* Update the geometry hints for the window */ + term_data_set_geometry_hints(td); - gtk_signal_connect_object( - GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_selector)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), - (gpointer)font_selector); + /* Reallocate the backing store */ + term_data_set_backing_store(td); - gtk_widget_show(GTK_WIDGET(font_selector)); -#endif + /* Hack - Show the window */ + gtk_widget_show_all(td->window); + +#ifdef USE_GRAPHICS + + /* We have to resize tiles when we are in graphics mode */ + resize_request = TRUE; + +#endif /* USE_GRAPHICS */ + + /* Hack - force redraw */ + Term_key_push(KTRL('R')); + + gtk_widget_destroy(font_selector); } @@ -3654,24 +3713,24 @@ GtkWidget *widget, gpointer user_data) { - term_data *td = (term_data *)user_data; + term_data *td = (term_data *)user_data; - /* We don't mess with the Angband window */ - if (td == &data[0]) return; - - /* It's shown */ - if (td->shown) - { - /* Hide the window */ - gtk_widget_hide_all(td->window); - } + /* We don't mess with the Angband window */ + if (td == &data[0]) return; - /* It's hidden */ - else - { - /* Show the window */ - gtk_widget_show_all(td->window); - } + /* It's shown */ + if (td->shown) + { + /* Hide the window */ + gtk_widget_hide_all(td->window); + } + + /* It's hidden */ + else + { + /* Show the window */ + gtk_widget_show_all(td->window); + } } @@ -3683,16 +3742,16 @@ GtkButton *was_clicked, gpointer user_data) { - int i; + int i; - /* Toggle the backing store mode */ - use_backing_store = !use_backing_store; + /* Toggle the backing store mode */ + use_backing_store = !use_backing_store; - /* Reset terms */ - for (i = 0; i < MAX_TERM_DATA; i++) - { - term_data_set_backing_store(&data[i]); - } + /* Reset terms */ + for (i = 0; i < MAX_TERM_DATA; i++) + { + term_data_set_backing_store(&data[i]); + } } @@ -3706,14 +3765,14 @@ GtkButton *was_clicked, gpointer user_data) { - /* Set request according to user selection */ - graf_mode_request = (int)user_data; + /* Set request according to user selection */ + graf_mode_request = (int)user_data; - /* - * Hack - force redraw - * This induces a call to Term_xtra(TERM_XTRA_REACT, 0) as well - */ - Term_key_push(KTRL('R')); + /* + * Hack - force redraw + * This induces a call to Term_xtra(TERM_XTRA_REACT, 0) as well + */ + Term_key_push(KTRL('R')); } @@ -3724,13 +3783,13 @@ GtkButton *was_clicked, gpointer user_data) { - /* Set request according to user selection */ - dith_mode = (int)user_data; + /* Set request according to user selection */ + dith_mode = (int)user_data; - /* - * Hack - force redraw - */ - Term_key_push(KTRL('R')); + /* + * Hack - force redraw + */ + Term_key_push(KTRL('R')); } @@ -3741,14 +3800,14 @@ GtkButton *was_clicked, gpointer user_data) { - /* (Try to) toggle the smooth rescaling mode */ - smooth_rescaling_request = !smooth_rescaling; + /* (Try to) toggle the smooth rescaling mode */ + smooth_rescaling_request = !smooth_rescaling; - /* - * Hack - force redraw - * This induces a call to Term_xtra(TERM_XTRA_REACT, 0) as well - */ - Term_key_push(KTRL('R')); + /* + * Hack - force redraw + * This induces a call to Term_xtra(TERM_XTRA_REACT, 0) as well + */ + Term_key_push(KTRL('R')); } @@ -3758,43 +3817,43 @@ GtkButton *was_clicked, gpointer user_data) { - term *old = Term; - term_data *td = &data[0]; + term *old = Term; + term_data *td = &data[0]; - /* Toggle "use_bigtile" */ - use_bigtile = !use_bigtile; + /* Toggle "use_bigtile" */ + use_bigtile = !use_bigtile; #ifdef TOME - /* T.o.M.E. requires this as well */ - arg_bigtile = use_bigtile; + /* T.o.M.E. requires this as well */ + arg_bigtile = use_bigtile; #endif /* TOME */ - /* Double the width of tiles (only for the main window) */ - if (use_bigtile) - { - td->tile_wid = td->font_wid * 2; - } - - /* Use the width of current font */ - else - { - td->tile_wid = td->font_wid; - } - - /* Need to resize the tiles */ - resize_request = TRUE; + /* Double the width of tiles (only for the main window) */ + if (use_bigtile) + { + td->tile_wid = td->font_wid * 2; + } + + /* Use the width of current font */ + else + { + td->tile_wid = td->font_wid; + } + + /* Need to resize the tiles */ + resize_request = TRUE; + + /* Activate the main window */ + Term_activate(&td->t); - /* Activate the main window */ - Term_activate(&td->t); + /* Resize the term */ + Term_resize(td->cols, td->rows); - /* Resize the term */ - Term_resize(td->cols, td->rows); + /* Activate the old term */ + Term_activate(old); - /* Activate the old term */ - Term_activate(old); - - /* Hack - force redraw XXX ??? XXX */ - Term_key_push(KTRL('R')); + /* Hack - force redraw XXX ??? XXX */ + Term_key_push(KTRL('R')); } # endif /* USE_DOUBLE_TILES */ @@ -3809,11 +3868,11 @@ GtkButton *was_clicked, gpointer user_data) { - /* Toggle the transparency mode */ - use_transparency = !use_transparency; + /* Toggle the transparency mode */ + use_transparency = !use_transparency; - /* Hack - force redraw */ - Term_key_push(KTRL('R')); + /* Hack - force redraw */ + Term_key_push(KTRL('R')); } # endif /* USE_TRANSPARENCY */ @@ -3831,25 +3890,25 @@ GtkWidget *widget, GtkWidget *file_selector) { - strcpy(savefile, - gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector))); + strcpy(savefile, + gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector))); - gtk_widget_destroy(file_selector); + gtk_widget_destroy(file_selector); - /* game is in progress */ - game_in_progress = TRUE; + /* game is in progress */ + game_in_progress = TRUE; - /* Flush input */ - Term_flush(); + /* Flush input */ + Term_flush(); - /* Play game */ - play_game(FALSE); + /* Play game */ + play_game(FALSE); - /* Free memory allocated by game */ - cleanup_angband(); + /* Free memory allocated by game */ + cleanup_angband(); - /* Done */ - quit(NULL); + /* Done */ + quit(NULL); } @@ -3860,47 +3919,47 @@ GtkButton *was_clicked, gpointer user_data) { - GtkWidget *file_selector; - char buf[1024]; + GtkWidget *file_selector; + char buf[1024]; - if (game_in_progress) - { - plog("You can't open a new game while you're still playing!"); - return; - } - - /* Prepare the savefile path */ - path_build(buf, 1024, ANGBAND_DIR_SAVE, "*"); - - file_selector = gtk_file_selection_new("Select a savefile"); - gtk_file_selection_set_filename( - GTK_FILE_SELECTION(file_selector), - buf); - gtk_signal_connect( - GTK_OBJECT(GTK_FILE_SELECTION(file_selector)->ok_button), - "clicked", - file_ok_callback, - (gpointer)file_selector); - - /* - * Ensure that the dialog box is destroyed when the user - * clicks a button. - */ - gtk_signal_connect_object( - GTK_OBJECT(GTK_FILE_SELECTION(file_selector)->ok_button), - "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), - (gpointer)file_selector); - - gtk_signal_connect_object( - GTK_OBJECT(GTK_FILE_SELECTION(file_selector)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), - (gpointer)file_selector); + if (game_in_progress) + { + plog("You can't open a new game while you're still playing!"); + return; + } + + /* Prepare the savefile path */ + path_build(buf, 1024, ANGBAND_DIR_SAVE, "*"); + + file_selector = gtk_file_selection_new("Select a savefile"); + gtk_file_selection_set_filename( + GTK_FILE_SELECTION(file_selector), + buf); + gtk_signal_connect( + GTK_OBJECT(GTK_FILE_SELECTION(file_selector)->ok_button), + "clicked", + file_ok_callback, + (gpointer)file_selector); + + /* + * Ensure that the dialog box is destroyed when the user + * clicks a button. + */ + gtk_signal_connect_object( + GTK_OBJECT(GTK_FILE_SELECTION(file_selector)->ok_button), + "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), + (gpointer)file_selector); + + gtk_signal_connect_object( + GTK_OBJECT(GTK_FILE_SELECTION(file_selector)->cancel_button), + "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), + (gpointer)file_selector); - gtk_window_set_modal(GTK_WINDOW(file_selector), TRUE); - gtk_widget_show(GTK_WIDGET(file_selector)); + gtk_window_set_modal(GTK_WINDOW(file_selector), TRUE); + gtk_widget_show(GTK_WIDGET(file_selector)); } #endif /* !SAVEFILE_SCREEN */ @@ -3914,11 +3973,11 @@ GdkEvent *event, gpointer user_data) { - /* Save game if possible */ - save_game_gtk(); + /* Save game if possible */ + save_game_gtk(); - /* Don't prevent closure */ - return (FALSE); + /* Don't prevent closure */ + return (FALSE); } @@ -3932,68 +3991,68 @@ gpointer user_data) { #if 1 - int i, mc, ms, mo, mx; + int i, mc, ms, mo, mx; - char msg[128]; + char msg[128]; - /* Hack - do not do anything until the player picks from the menu */ - if (!game_in_progress) return (TRUE); + /* Hack - do not do anything until the player picks from the menu */ + if (!game_in_progress) return (TRUE); - /* Hack - Ignore parameters */ - (void) widget; - (void) user_data; + /* Hack - Ignore parameters */ + (void) widget; + (void) user_data; + + /* Extract four "modifier flags" */ + mc = (event->state & GDK_CONTROL_MASK) ? TRUE : FALSE; + ms = (event->state & GDK_SHIFT_MASK) ? TRUE : FALSE; + mo = (event->state & GDK_MOD1_MASK) ? TRUE : FALSE; + mx = (event->state & GDK_MOD3_MASK) ? TRUE : FALSE; + + /* + * Hack XXX + * Parse shifted numeric (keypad) keys specially. + */ + if ((event->state == GDK_SHIFT_MASK) + && (event->keyval >= GDK_KP_0) && (event->keyval <= GDK_KP_9)) + { + /* Build the macro trigger string */ + strnfmt(msg, 128, "%cS_%X%c", 31, event->keyval, 13); + + /* Enqueue the "macro trigger" string */ + for (i = 0; msg[i]; i++) Term_keypress(msg[i]); + + /* Hack -- auto-define macros as needed */ + if (event->length && (macro_find_exact(msg) < 0)) + { + /* Create a macro */ + macro_add(msg, event->string); + } + + return (TRUE); + } + + /* Normal keys with no modifiers */ + if (event->length && !mo && !mx) + { + /* Enqueue the normal key(s) */ + for (i = 0; i < event->length; i++) Term_keypress(event->string[i]); + + /* All done */ + return (TRUE); + } + + + /* Handle a few standard keys (bypass modifiers) XXX XXX XXX */ + switch ((uint) event->keyval) + { + case GDK_Escape: + { + Term_keypress(ESCAPE); + return (TRUE); + } - /* Extract four "modifier flags" */ - mc = (event->state & GDK_CONTROL_MASK) ? TRUE : FALSE; - ms = (event->state & GDK_SHIFT_MASK) ? TRUE : FALSE; - mo = (event->state & GDK_MOD1_MASK) ? TRUE : FALSE; - mx = (event->state & GDK_MOD3_MASK) ? TRUE : FALSE; - - /* - * Hack XXX - * Parse shifted numeric (keypad) keys specially. - */ - if ((event->state == GDK_SHIFT_MASK) - && (event->keyval >= GDK_KP_0) && (event->keyval <= GDK_KP_9)) - { - /* Build the macro trigger string */ - strnfmt(msg, 128, "%cS_%X%c", 31, event->keyval, 13); - - /* Enqueue the "macro trigger" string */ - for (i = 0; msg[i]; i++) Term_keypress(msg[i]); - - /* Hack -- auto-define macros as needed */ - if (event->length && (macro_find_exact(msg) < 0)) - { - /* Create a macro */ - macro_add(msg, event->string); - } - - return (TRUE); - } - - /* Normal keys with no modifiers */ - if (event->length && !mo && !mx) - { - /* Enqueue the normal key(s) */ - for (i = 0; i < event->length; i++) Term_keypress(event->string[i]); - - /* All done */ - return (TRUE); - } - - - /* Handle a few standard keys (bypass modifiers) XXX XXX XXX */ - switch ((uint) event->keyval) - { - case GDK_Escape: - { - Term_keypress(ESCAPE); - return (TRUE); - } - - case GDK_Return: - { + case GDK_Return: + { Term_keypress('\r'); return (TRUE); } @@ -5057,14 +5116,12 @@ /* Set title */ gtk_window_set_title(GTK_WINDOW(td->window), td->name); - /* Get default font for this term */ font = get_default_font(i); /* Load font and initialise related term_data fields */ load_font(td, font); - /* Create drawing area */ td->drawing_area = gtk_drawing_area_new(); @@ -5216,6 +5273,7 @@ #endif /* ANGBAND300 */ + /* * Initialization function */ diff -Naur tome-231-src/src/main-win.c tome-231-src/src/main-win.c --- tome-231-src/src/main-win.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/main-win.c 2005-04-07 07:38:28.000000000 -0700 @@ -2121,8 +2121,11 @@ * One would think there is a more efficient method for telling a window * what color it should be using to draw with, but perhaps simply changing * it every time is not too inefficient. XXX XXX XXX + * + * TODO: For unicode support, update ExtTextOut. It accepts u16b unicode, + * which is what glyf is. Check MSDN. - Leon Torres */ -static errr Term_text_win(int x, int y, int n, byte a, const char *s) +static errr Term_text_win(int x, int y, int n, byte a, const glyf *s) { term_data *td = (term_data*)(Term->data); RECT rc; @@ -2218,12 +2221,12 @@ */ # ifdef USE_TRANSPARENCY # ifdef USE_EGO_GRAPHICS -static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp, const byte *eap, const char *ecp) +static errr Term_pict_win(int x, int y, int n, const byte *ap, const glyf *cp, const byte *tap, const glyf *tcp, const byte *eap, const glyf *ecp) # else /* USE_EGO_GRAPHICS */ -static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp) +static errr Term_pict_win(int x, int y, int n, const byte *ap, const glyf *cp, const byte *tap, const glyf *tcp) # endif /* USE_EGO_GRAPHICS */ # else /* USE_TRANSPARENCY */ -static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp) +static errr Term_pict_win(int x, int y, int n, const byte *ap, const glyf *cp) # endif /* USE_TRANSPARENCY */ { term_data *td = (term_data*)(Term->data); @@ -2296,7 +2299,7 @@ for (i = 0; i < n; i++, x2 += w2) { byte a = ap[i]; - char c = cp[i]; + glyf c = cp[i]; /* Extract picture */ int row = (a & 0x7F); diff -Naur tome-231-src/src/makefile.gtk tome-231-src/src/makefile.gtk --- tome-231-src/src/makefile.gtk 1969-12-31 16:00:00.000000000 -0800 +++ tome-231-src/src/makefile.gtk 2005-04-07 06:38:45.000000000 -0700 @@ -0,0 +1,324 @@ +# File: Makefile + +# +# Note that you may have to make modifications below according +# to your machine, available libraries, compilation options, +# and your "visual module" of choice. This Makefile is intended +# for use with systems that have GTK+ installed. +# + +## +## 1. Installation locations and such +## +## LIBDIR, BINDIR and OWNER should be set appropriately for +## multiuser installations. +## +## If you want to keep it private or don't have root privilege +## required by "make install", set LIBDIR to ./lib/ or an absolute +## path pointing to your lib directory, and don't run "make install". +## +## NOTE: If LIBDIR is set to ./lib/ , you have to cd to parent directory +## of lib before you start the game. +## + +# Where lib/ files goes +#LIBDIR = /usr/lib/games/tome/ +# Sysadmins of commercial Unix and/or BSD might prefer this +#LIBDIR = /usr/local/lib/tome/ +# If you like the old default, use this one +LIBDIR = ./lib/ +# Another example: single user installation using absolute path +#LIBDIR = /home/myloginname/lib/tome/ + + +# Where ToME binary goes +BINDIR = /usr/local/games +# Another common location +#BINDIR = /usr/local/bin + +# The game will run suid to this user +OWNER = games + +# Ignore this if you're not making a package +DESTDIR= + +## +## 2. Some "system" definitions +## +## No changes are needed to compile a version that will run on both +## X11 and Curses, in debugging mode, with maximal warnings, on many +## normal Unix machines of the Sun OS variety (non-solaris). +## +## To use an "alternative" definition, simply "modify" (or "replace") +## the definition below with one that you like. For example, you can +## change the compiler to "cc", or remove the "debugging" options, or +## remove the X11 or Curses support, etc, as desired. +## +## See also "config.h" and "h-config.h" for important information. +## +## Some "examples" are given below, they can be used by simply +## removing the FIRST column of "#" signs from the "block" of lines +## you wish to use, and commenting out "standard" block below. +## +## This is not intended to be a "good" Makefile, just a "simple" one. +## + + +# +# This is my compiler of choice, it seems to work most everywhere +# +CC = gcc + +# Profiling options +# PROFILECOPTS = -pg +# PROFILELDFLAGS = -pg + +# +# GTK+ verson 2 (main-gtk2.c) +# +COPTS = -Wall -O1 -pipe -g +INCLUDES = `pkg-config --cflags gtk+-2.0` +DEFINES = -DUSE_GTK2 -DUSE_TRANSPARENCY -DUSE_EGO_GRAPHICS -DSUPPORT_GAMMA +LIBS = `pkg-config --libs gtk+-2.0` + +# +# GTK+ version 1 (main-gtk.c) +# +# Uncomment the following if you use GTK version 1. +# +#COPTS = -Wall -O1 -pipe -g +#INCLUDES = `gtk-config --cflags` +#DEFINES = -DUSE_GTK -DUSE_TRANSPARENCY -DUSE_EGO_GRAPHICS -DSUPPORT_GAMMA +#LIBS = `gtk-config --libs` + + +### End of configurable section ### + +# +# The "source" and "object" files. +# + +BASESRCS = \ + main-gtk2.c main-gcu.c main-x11.c main-xaw.c main-sdl.c main-dmy.c \ + z-rand.c z-util.c z-form.c z-virt.c z-term.c z-sock.c \ + variable.c tables.c plots.c util.c cave.c dungeon.c \ + melee1.c melee2.c modules.c \ + object1.c object2.c randart.c squeltch.c traps.c \ + monster1.c monster2.c monster3.c ghost.c \ + xtra1.c xtra2.c skills.c powers.c gods.c \ + spells1.c spells2.c \ + status.c files.c notes.c loadsave.c \ + cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c cmd7.c \ + help.c \ + generate.c gen_maze.c gen_evol.c wild.c levels.c store.c bldg.c \ + cmovie.c irc.c \ + wizard2.c init2.c birth.c wizard1.c init1.c main.c + +BASEOBJS = \ + main-gtk2.o main-gcu.o main-x11.o main-xaw.o main-sdl.o main-dmy.o \ + z-rand.o z-util.o z-form.o z-virt.o z-term.o z-sock.o \ + variable.o tables.o plots.o util.o cave.o dungeon.o \ + melee1.o melee2.o modules.o \ + object1.o object2.o randart.o squeltch.o traps.o \ + monster1.o monster2.o monster3.o ghost.o \ + xtra1.o xtra2.o skills.o powers.o gods.o \ + spells1.o spells2.o \ + status.o files.o notes.o loadsave.o \ + cmd1.o cmd2.o cmd3.o cmd4.o cmd5.o cmd6.o cmd7.o \ + help.o \ + generate.o gen_maze.o gen_evol.o wild.o levels.o store.o bldg.o \ + cmovie.o irc.o \ + wizard2.o init2.o birth.o wizard1.o init1.o main.o + +LUASRCS = \ + script.c lua_bind.c \ + w_util.c w_player.c w_z_pack.c w_obj.c w_mnster.c w_spells.c w_quest.c w_play_c.c w_dun.c + +TOLUASRCS = \ + lua/lapi.c lua/lcode.c lua/ldebug.c lua/ldo.c lua/lfunc.c lua/lgc.c \ + lua/llex.c lua/lmem.c lua/lobject.c lua/lparser.c lua/lstate.c lua/lstring.c \ + lua/ltable.c lua/ltests.c lua/ltm.c lua/lundump.c lua/lvm.c lua/lzio.c \ + lua/lauxlib.c lua/lbaselib.c lua/ldblib.c lua/liolib.c lua/lstrlib.c \ + lua/tolua_lb.c lua/tolua_rg.c lua/tolua_tt.c lua/tolua_tm.c lua/tolua_gp.c \ + lua/tolua_eh.c lua/tolua_bd.c + +LUAOBJS = \ + script.o lua_bind.o \ + w_util.o w_player.o w_z_pack.o w_obj.o w_mnster.o w_spells.o w_quest.o w_play_c.o w_dun.o + +TOLUAOBJS = \ + lua/lapi.o lua/lcode.o lua/ldebug.o lua/ldo.o lua/lfunc.o lua/lgc.o \ + lua/llex.o lua/lmem.o lua/lobject.o lua/lparser.o lua/lstate.o lua/lstring.o \ + lua/ltable.o lua/ltests.o lua/ltm.o lua/lundump.o lua/lvm.o lua/lzio.o \ + lua/lauxlib.o lua/lbaselib.o lua/ldblib.o lua/liolib.o lua/lstrlib.o \ + lua/tolua_lb.o lua/tolua_rg.o lua/tolua_tt.o lua/tolua_tm.o lua/tolua_gp.o \ + lua/tolua_eh.o lua/tolua_bd.o + +# +# Base sources and objects +# + +SRCS = $(BASESRCS) +OBJS = $(BASEOBJS) + + +# +# Compiler options +# + +CFLAGS = $(COPTS) $(PROFILECOPTS) $(INCLUDES) $(DEFINES) -DDEFAULT_PATH=\"$(LIBDIR)\" + + +# +# Lua support +# + +INCLUDES += -Ilua -I. +DEFINES += -DUSE_LUA +SRCS = $(LUASRCS) $(TOLUASRCS) $(BASESRCS) +OBJS = $(LUAOBJS) $(TOLUAOBJS) $(BASEOBJS) + +# Force recreation of stub files when lua source files are updated +# To be included in dependency rules +TOLUADEP = $(TOLUASRCS) lua/tolua.c lua/tolualua.c + +# +# IRC support +# + +IRC_SERVER=irc.worldirc.org +IRC_PORT=6667 +IRC_CHANNEL=\#tome + +DEFINES += \ + -DIRC_SERVER=\"$(IRC_SERVER)\" \ + -DIRC_PORT=\"$(IRC_PORT)\" \ + -DIRC_CHANNEL=\"$(IRC_CHANNEL)\" + +# Build the binary. The new base target. +# + +TARGET = tome + +TOLUA = ./tolua + +default: $(TOLUA) $(TARGET) +# @echo "*** Note: In order to use the install rule, which now actually" +# @echo "*** handles the installation of the library dir, you need to edit" +# @echo "*** this makefile, going to the top and making sure LIBDIR suits" +# @echo "*** your desired install dir properly. The LIBRARY_DIR you used" +# @echo "*** to set in config.h is now ignored and obsolete with respect" +# @echo "*** to this makefile. Note that if you edit this makefile, you may" +# @echo "*** need to recompile so all the files that reference those defines" +# @echo "*** notice the changes." + +$(TARGET): $(OBJS) + $(CC) $(PROFILELDFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + +$(TOLUA): $(TOLUAOBJS) lua/tolua.c lua/tolualua.c + $(CC) $(CFLAGS) $(PROFILELDFLAGS) $(LDFLAGS) -o $@ $(TOLUAOBJS) lua/tolua.c lua/tolualua.c $(LIBS) + +# +# An install rule. +# +mini_install: default + cp -f $(TARGET) .. + +install: default + [ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR) + [ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) + cp -r ../lib/* $(DESTDIR)$(LIBDIR) + chown -R $(OWNER) $(DESTDIR)$(LIBDIR) + cp -f $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET) + chown $(OWNER) $(DESTDIR)$(BINDIR)/$(TARGET) + chmod 4755 $(DESTDIR)$(BINDIR)/$(TARGET) + +# old-install: $(TARGET) +# cp $(TARGET) .. + + +# +# Clean up old junk +# + +clean: + rm -f *.bak *.o lua/*.o w_*.c + + +# Make a src dist +TARGET_VERSION=`fgrep '[V]' ../changes.txt | sed 's/\[V\]-\s*T.o.M.E \(.\).\(.\).\(.\) .*/\1\2\3/g'` +DIST_TARGET_VERSION=../dist/tome-$(TARGET_VERSION)-src +DIST_TARGET=../dist/tome-xxx-src +dist: clean + mkdir -p $(DIST_TARGET) + cp -r ../lib $(DIST_TARGET) + cp -r ../src $(DIST_TARGET) + ../tome -c ../changes.txt $(DIST_TARGET)/changes.txt + cp ../changes.old $(DIST_TARGET) + cp ../credits.txt $(DIST_TARGET) + cp ../tome.ini $(DIST_TARGET) + cp ../angdos.cfg $(DIST_TARGET) + rm -f $(DIST_TARGET)/src/tome $(DIST_TARGET)/src/tolua + find $(DIST_TARGET) -name '*~' -exec rm {} \; + find $(DIST_TARGET)/lib/data/ -name '*.raw' -exec rm {} \; + find $(DIST_TARGET)/lib/xtra/graf/ -name '*.gif' -exec rm {} \; + find $(DIST_TARGET)/lib/xtra/font/ -name '*.hex' -exec rm {} \; + rm -rf `find $(DIST_TARGET) -name 'CVS'` + rm -rf `find $(DIST_TARGET)/lib/mods/ -mindepth 1 -maxdepth 1 -type d` + sed -i 's/(CVS)//' $(DIST_TARGET)/src/defines.h + mv $(DIST_TARGET) $(DIST_TARGET_VERSION) + cd ../dist; tar -cvjf tome-$(TARGET_VERSION)-src.tar.bz2 tome-$(TARGET_VERSION)-src + +# +# Generate dependancies automatically +# + +depend: + makedepend $(INCLUDES) $(DEFINES) -D__MAKEDEPEND__ $(SRCS) + +.c.o: + $(CC) $(CFLAGS) -c -o $*.o $*.c + + +# +# Quests +# +plots.o: q_rand.c q_main.c q_one.c q_ultrag.c q_ultrae.c \ + q_thief.c q_hobbit.c q_nazgul.c q_troll.c q_wight.c \ + q_spider.c q_poison.c \ + q_eol.c q_nirna.c q_invas.c \ + q_betwen.c \ + q_narsil.c q_shroom.c q_thrain.c q_wolves.c q_dragons.c q_haunted.c q_evil.c + +# +# Lua library compilation rules +# + +w_mnster.c: monster.pkg $(TOLUADEP) + $(TOLUA) -n monster -o w_mnster.c monster.pkg + +w_player.c: player.pkg $(TOLUADEP) + $(TOLUA) -n player -o w_player.c player.pkg + +w_play_c.c: player_c.pkg $(TOLUADEP) + $(TOLUA) -n player_c -o w_play_c.c player_c.pkg + +w_z_pack.c: z_pack.pkg $(TOLUADEP) + $(TOLUA) -n z_pack -o w_z_pack.c z_pack.pkg + +w_obj.c: object.pkg $(TOLUADEP) + $(TOLUA) -n object -o w_obj.c object.pkg + +w_util.c: util.pkg $(TOLUADEP) + $(TOLUA) -n util -o w_util.c util.pkg + +w_spells.c: spells.pkg $(TOLUADEP) + $(TOLUA) -n spells -o w_spells.c spells.pkg + +w_quest.c: quest.pkg $(TOLUADEP) + $(TOLUA) -n quest -o w_quest.c quest.pkg + +w_dun.c: dungeon.pkg $(TOLUA) + $(TOLUA) -n dungeon -o w_dun.c dungeon.pkg + +# DO NOT DELETE THIS LINE - make depend depends on it. diff -Naur tome-231-src/src/monster1.c tome-231-src/src/monster1.c --- tome-231-src/src/monster1.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/monster1.c 2005-04-07 04:48:08.000000000 -0700 @@ -1626,7 +1626,8 @@ monster_race *r_ptr = race_info_idx(r_idx, ego); byte a1, a2; - char c1, c2; + char c1; + glyf c2; /* Access the chars */ diff -Naur tome-231-src/src/spells1.c tome-231-src/src/spells1.c --- tome-231-src/src/spells1.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/spells1.c 2005-04-07 04:48:18.000000000 -0700 @@ -1226,7 +1226,7 @@ byte k; byte a; - char c; + glyf c; /* No motion (*) */ if ((ny == y) && (nx == x)) base = 0x30; @@ -8488,7 +8488,7 @@ u16b p; byte a; - char c; + glyf c; /* Obtain the bolt pict */ p = bolt_pict(oy, ox, y, x, typ); @@ -8620,7 +8620,7 @@ u16b p; byte a; - char c; + glyf c; drawn = TRUE; diff -Naur tome-231-src/src/types.h tome-231-src/src/types.h --- tome-231-src/src/types.h 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/types.h 2005-04-07 04:50:31.000000000 -0700 @@ -143,8 +143,8 @@ byte x_attr; /* Desired feature attribute */ - char x_char; /* Desired feature character */ - + glyf x_char; /* Desired feature character */ + byte shimmer[7]; /* Shimmer colors */ int d_dice[4]; /* Number of dices */ @@ -211,7 +211,7 @@ byte x_attr; /* Desired object attribute */ - char x_char; /* Desired object character */ + glyf x_char; /* Desired object character */ byte flavor; /* Special object flavor (or zero) */ @@ -502,7 +502,7 @@ byte x_attr; /* Desired monster attribute */ - char x_char; /* Desired monster character */ + glyf x_char; /* Desired monster character */ s16b max_num; /* Maximum population allowed per level */ @@ -620,8 +620,8 @@ byte g_attr; /* Overlay graphic attribute */ char g_char; /* Overlay graphic character */ - char r_char[5]; /* Monster race allowed */ - char nr_char[5]; /* Monster race not allowed */ + glyf r_char[5]; /* Monster race allowed */ + glyf nr_char[5]; /* Monster race not allowed */ }; @@ -1076,7 +1076,7 @@ char d_char; /* Default building character */ byte x_attr; /* Desired building attribute */ - char x_char; /* Desired building character */ + glyf x_char; /* Desired building character */ u32b flags1; /* Flags */ }; diff -Naur tome-231-src/src/util.c tome-231-src/src/util.c --- tome-231-src/src/util.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/util.c 2005-04-07 04:48:25.000000000 -0700 @@ -3056,7 +3056,7 @@ int i, n = 0; byte av[256]; - char cv[256]; + glyf cv[256]; /* Wrap word */ if (x < wrap) @@ -4824,3 +4824,46 @@ else cmsg_print(TERM_VIOLET, "Unknown timer!"); } + +/* + * Converts an array of UTF-32 values to a UTF-8 encoded string. Arguments + * are the glyf array, the length of the array, and a buffer to write to. + * The buffer must be at least size (3*n)+1. Returns the number of bytes + * written, which is effectively the length of the string. The string is + * guaranteed to be null-terminated. + * + * XXX Warning: Don't encode text pieced together inside legacy functions, + * such as object_desc. Term_queue_chars needs to be updated to handle + * wide characters first. XXX + */ +int glyf_ary_to_utf8(const glyf *a, int n, char *s) +{ + int i; + int j = 0; + + for (i = 0; i < n; i++) + { + if (!(a[i] & 0xFFFFFF80)) + { + // Normal char or 0x00 to 0x7F in 1 byte + s[j++] = a[i]; + } + else if (!(a[i] & 0xFFFFF800)) + { + // 0x80 to 0x7FF in 2 bytes: 110xxxxx 10xxxxxx + s[j++] = 0xC0 | (a[i] >> 6); + s[j++] = 0x80 | (a[i] & 0x3F); + } + else + { + // 0x800 to 0xFFFF in 3 bytes: 1110xxxx 10xxxxxx 10xxxxxx + s[j++] = 0xE0 | (a[i] >> 12); + s[j++] = 0x80 | ((a[i] >> 6) & 0x3F); + s[j++] = 0x80 | (a[i] & 0x3F); + } + /* TODO: up to 10FFFF */ + } + s[j] = '\0'; + + return j; +} diff -Naur tome-231-src/src/z-term.c tome-231-src/src/z-term.c --- tome-231-src/src/z-term.c 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/z-term.c 2005-04-07 06:25:12.000000000 -0700 @@ -294,31 +294,31 @@ { /* Free the window access arrays */ C_KILL(s->a, h, byte*); - C_KILL(s->c, h, char*); + C_KILL(s->c, h, glyf*); /* Free the window content arrays */ C_KILL(s->va, h * w, byte); - C_KILL(s->vc, h * w, char); + C_KILL(s->vc, h * w, glyf); #ifdef USE_TRANSPARENCY /* Free the terrain access arrays */ C_KILL(s->ta, h, byte*); - C_KILL(s->tc, h, char*); + C_KILL(s->tc, h, glyf*); /* Free the terrain content arrays */ C_KILL(s->vta, h * w, byte); - C_KILL(s->vtc, h * w, char); + C_KILL(s->vtc, h * w, glyf); #ifdef USE_EGO_GRAPHICS /* Free the ego graphics access arrays */ C_KILL(s->ea, h, byte*); - C_KILL(s->ec, h, char*); + C_KILL(s->ec, h, glyf*); /* Free the ego graphics content arrays */ C_KILL(s->vea, h * w, byte); - C_KILL(s->vec, h * w, char); + C_KILL(s->vec, h * w, glyf); #endif /* USE_EGO_GRAPHICS */ @@ -338,31 +338,31 @@ /* Make the window access arrays */ C_MAKE(s->a, h, byte*); - C_MAKE(s->c, h, char*); + C_MAKE(s->c, h, glyf*); /* Make the window content arrays */ C_MAKE(s->va, h * w, byte); - C_MAKE(s->vc, h * w, char); + C_MAKE(s->vc, h * w, glyf); #ifdef USE_TRANSPARENCY /* Make the terrain access arrays */ C_MAKE(s->ta, h, byte*); - C_MAKE(s->tc, h, char*); + C_MAKE(s->tc, h, glyf*); /* Make the terrain content arrays */ C_MAKE(s->vta, h * w, byte); - C_MAKE(s->vtc, h * w, char); + C_MAKE(s->vtc, h * w, glyf); #ifdef USE_EGO_GRAPHICS /* Make the ego graphics access arrays */ C_MAKE(s->ea, h, byte*); - C_MAKE(s->ec, h, char*); + C_MAKE(s->ec, h, glyf*); /* Make the ego graphics content arrays */ C_MAKE(s->vea, h * w, byte); - C_MAKE(s->vec, h * w, char); + C_MAKE(s->vec, h * w, glyf); #endif /* USE_EGO_GRAPHICS */ @@ -407,26 +407,26 @@ for (y = 0; y < h; y++) { byte *f_aa = f->a[y]; - char *f_cc = f->c[y]; + glyf *f_cc = f->c[y]; byte *s_aa = s->a[y]; - char *s_cc = s->c[y]; + glyf *s_cc = s->c[y]; #ifdef USE_TRANSPARENCY byte *f_taa = f->ta[y]; - char *f_tcc = f->tc[y]; + glyf *f_tcc = f->tc[y]; byte *s_taa = s->ta[y]; - char *s_tcc = s->tc[y]; + glyf *s_tcc = s->tc[y]; #ifdef USE_EGO_GRAPHICS byte *f_eaa = f->ea[y]; - char *f_ecc = f->ec[y]; + glyf *f_ecc = f->ec[y]; byte *s_eaa = s->ea[y]; - char *s_ecc = s->ec[y]; + glyf *s_ecc = s->ec[y]; #endif /* USE_EGO_GRAPHICS */ @@ -526,7 +526,7 @@ /* * Hack -- fake hook for "Term_text()" (see above) */ -static errr Term_text_hack(int x, int y, int n, byte a, const char *cp) +static errr Term_text_hack(int x, int y, int n, byte a, const glyf *cp) { /* Compiler silliness */ if (x || y || n || a || cp) return ( -2); @@ -540,12 +540,12 @@ */ #ifdef USE_TRANSPARENCY #ifdef USE_EGO_GRAPHICS -static errr Term_pict_hack(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp, const byte *eap, const char *ecp) +static errr Term_pict_hack(int x, int y, int n, const byte *ap, const glyf *cp, const byte *tap, const glyf *tcp, const byte *eap, const glyf *ecp) #else /* USE_EGO_GRAPHICS */ -static errr Term_pict_hack(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp) +static errr Term_pict_hack(int x, int y, int n, const byte *ap, const glyf *cp, const byte *tap, const glyf *tcp) #endif /* USE_EGO_GRAPHICS */ #else /* USE_TRANSPARENCY */ -static errr Term_pict_hack(int x, int y, int n, const byte *ap, const char *cp) +static errr Term_pict_hack(int x, int y, int n, const byte *ap, const glyf *cp) #endif /* USE_TRANSPARENCY */ { /* Compiler silliness */ @@ -575,28 +575,28 @@ */ #ifdef USE_TRANSPARENCY #ifdef USE_EGO_GRAPHICS -void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc, byte ea, char ec) +void Term_queue_char(int x, int y, byte a, glyf c, byte ta, glyf tc, byte ea, glyf ec) #else /* USE_EGO_GRAPHICS */ -void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc) +void Term_queue_char(int x, int y, byte a, glyf c, byte ta, glyf tc) #endif /* USE_EGO_GRAPHICS */ #else /* USE_TRANSPARENCY */ -void Term_queue_char(int x, int y, byte a, char c) +void Term_queue_char(int x, int y, byte a, glyf c) #endif /* USE_TRANSPARENCY */ { term_win *scrn = Term->scr; byte *scr_aa = &scrn->a[y][x]; - char *scr_cc = &scrn->c[y][x]; + glyf *scr_cc = &scrn->c[y][x]; #ifdef USE_TRANSPARENCY byte *scr_taa = &scrn->ta[y][x]; - char *scr_tcc = &scrn->tc[y][x]; + glyf *scr_tcc = &scrn->tc[y][x]; #ifdef USE_EGO_GRAPHICS byte *scr_eaa = &scrn->ea[y][x]; - char *scr_ecc = &scrn->ec[y][x]; + glyf *scr_ecc = &scrn->ec[y][x]; /* Hack -- Ignore non-changes */ if ((*scr_aa == a) && (*scr_cc == c) && @@ -656,12 +656,12 @@ */ #ifdef USE_TRANSPARENCY #ifdef USE_EGO_GRAPHICS -void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc, byte *ea, char *ec) +void Term_queue_line(int x, int y, int n, byte *a, glyf *c, byte *ta, glyf *tc, byte *ea, glyf *ec) #else /* USE_EGO_GRAPHICS */ -void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc) +void Term_queue_line(int x, int y, int n, byte *a, glyf *c, byte *ta, glyf *tc) #endif /* USE_EGO_GRAPHICS */ #else /* USE_TRANSPARENCY */ -void Term_queue_line(int x, int y, int n, byte *a, char *c) +void Term_queue_line(int x, int y, int n, byte *a, glyf *c) #endif /* USE_TRANSPARENCY */ { term_win *scrn = Term->scr; @@ -670,17 +670,17 @@ int x2 = -1; byte *scr_aa = &scrn->a[y][x]; - char *scr_cc = &scrn->c[y][x]; + glyf *scr_cc = &scrn->c[y][x]; #ifdef USE_TRANSPARENCY byte *scr_taa = &scrn->ta[y][x]; - char *scr_tcc = &scrn->tc[y][x]; + glyf *scr_tcc = &scrn->tc[y][x]; #ifdef USE_EGO_GRAPHICS byte *scr_eaa = &scrn->ea[y][x]; - char *scr_ecc = &scrn->ec[y][x]; + glyf *scr_ecc = &scrn->ec[y][x]; #endif /* USE_EGO_GRAPHICS */ @@ -788,17 +788,17 @@ int x1 = -1, x2 = -1; byte *scr_aa = Term->scr->a[y]; - char *scr_cc = Term->scr->c[y]; + glyf *scr_cc = Term->scr->c[y]; #ifdef USE_TRANSPARENCY byte *scr_taa = Term->scr->ta[y]; - char *scr_tcc = Term->scr->tc[y]; + glyf *scr_tcc = Term->scr->tc[y]; #ifdef USE_EGO_GRAPHICS byte *scr_eaa = Term->scr->ea[y]; - char *scr_ecc = Term->scr->ec[y]; + glyf *scr_ecc = Term->scr->ec[y]; #endif /* USE_EGO_GRAPHICS */ #endif /* USE_TRANSPARENCY */ @@ -889,38 +889,38 @@ int x; byte *old_aa = Term->old->a[y]; - char *old_cc = Term->old->c[y]; + glyf *old_cc = Term->old->c[y]; byte *scr_aa = Term->scr->a[y]; - char *scr_cc = Term->scr->c[y]; + glyf *scr_cc = Term->scr->c[y]; #ifdef USE_TRANSPARENCY byte *old_taa = Term->old->ta[y]; - char *old_tcc = Term->old->tc[y]; + glyf *old_tcc = Term->old->tc[y]; byte *scr_taa = Term->scr->ta[y]; - char *scr_tcc = Term->scr->tc[y]; + glyf *scr_tcc = Term->scr->tc[y]; byte ota; - char otc; + glyf otc; byte nta; - char ntc; + glyf ntc; #ifdef USE_EGO_GRAPHICS byte *old_eaa = Term->old->ea[y]; - char *old_ecc = Term->old->ec[y]; + glyf *old_ecc = Term->old->ec[y]; byte *scr_eaa = Term->scr->ea[y]; - char *scr_ecc = Term->scr->ec[y]; + glyf *scr_ecc = Term->scr->ec[y]; byte oea; - char oec; + glyf oec; byte nea; - char nec; + glyf nec; #endif /* USE_EGO_GRAPHICS */ @@ -934,10 +934,10 @@ int fx = 0; byte oa; - char oc; + glyf oc; byte na; - char nc; + glyf nc; /* Scan "modified" columns */ for (x = x1; x <= x2; x++) @@ -1062,32 +1062,32 @@ int x; byte *old_aa = Term->old->a[y]; - char *old_cc = Term->old->c[y]; + glyf *old_cc = Term->old->c[y]; byte *scr_aa = Term->scr->a[y]; - char *scr_cc = Term->scr->c[y]; + glyf *scr_cc = Term->scr->c[y]; #ifdef USE_TRANSPARENCY byte *old_taa = Term->old->ta[y]; - char *old_tcc = Term->old->tc[y]; + glyf *old_tcc = Term->old->tc[y]; byte *scr_taa = Term->scr->ta[y]; - char *scr_tcc = Term->scr->tc[y]; + glyf *scr_tcc = Term->scr->tc[y]; byte ota; - char otc; + glyf otc; byte nta; - char ntc; + glyf ntc; #ifdef USE_EGO_GRAPHICS byte *old_eaa = Term->old->ea[y]; - char *old_ecc = Term->old->ec[y]; + glyf *old_ecc = Term->old->ec[y]; byte *scr_eaa = Term->scr->ea[y]; - char *scr_ecc = Term->scr->ec[y]; + glyf *scr_ecc = Term->scr->ec[y]; byte oea; - char oec; + glyf oec; byte nea; - char nec; + glyf nec; #endif /* USE_EGO_GRAPHICS */ #endif /* USE_TRANSPARENCY */ @@ -1105,10 +1105,10 @@ byte fa = Term->attr_blank; byte oa; - char oc; + glyf oc; byte na; - char nc; + glyf nc; /* Scan "modified" columns */ for (x = x1; x <= x2; x++) @@ -1298,10 +1298,10 @@ int x; byte *old_aa = Term->old->a[y]; - char *old_cc = Term->old->c[y]; + glyf *old_cc = Term->old->c[y]; byte *scr_aa = Term->scr->a[y]; - char *scr_cc = Term->scr->c[y]; + glyf *scr_cc = Term->scr->c[y]; /* The "always_text" flag */ int always_text = Term->always_text; @@ -1319,7 +1319,7 @@ char oc; byte na; - char nc; + glyf nc; /* Scan "modified" columns */ for (x = x1; x <= x2; x++) @@ -1589,17 +1589,17 @@ for (y = 0; y < h; y++) { byte *aa = old->a[y]; - char *cc = old->c[y]; + glyf *cc = old->c[y]; #ifdef USE_TRANSPARENCY byte *taa = old->ta[y]; - char *tcc = old->tc[y]; + glyf *tcc = old->tc[y]; #ifdef USE_EGO_GRAPHICS byte *eaa = old->ea[y]; - char *ecc = old->ec[y]; + glyf *ecc = old->ec[y]; #endif /* USE_EGO_GRAPHICS */ @@ -1656,26 +1656,26 @@ int ty = old->cy; byte *old_aa = old->a[ty]; - char *old_cc = old->c[ty]; + glyf *old_cc = old->c[ty]; byte oa = old_aa[tx]; - char oc = old_cc[tx]; + glyf oc = old_cc[tx]; #ifdef USE_TRANSPARENCY byte *old_taa = old->ta[ty]; - char *old_tcc = old->tc[ty]; + glyf *old_tcc = old->tc[ty]; byte ota = old_taa[tx]; - char otc = old_tcc[tx]; + glyf otc = old_tcc[tx]; #ifdef USE_EGO_GRAPHICS byte *old_eaa = old->ea[ty]; - char *old_ecc = old->ec[ty]; + glyf *old_ecc = old->ec[ty]; byte oea = old_eaa[tx]; - char oec = old_ecc[tx]; + glyf oec = old_ecc[tx]; #endif /* USE_EGO_GRAPHICS */ @@ -1919,7 +1919,7 @@ * Do not change the cursor position * No visual changes until "Term_fresh()". */ -errr Term_draw(int x, int y, byte a, char c) +errr Term_draw(int x, int y, byte a, glyf c) { int w = Term->wid; int h = Term->hgt; @@ -1963,7 +1963,7 @@ * positive value, future calls to either function will * return negative ones. */ -errr Term_addch(byte a, char c) +errr Term_addch(byte a, glyf c) { int w = Term->wid; @@ -2054,7 +2054,7 @@ /* * Move to a location and, using an attr, add a char */ -errr Term_putch(int x, int y, byte a, char c) +errr Term_putch(int x, int y, byte a, glyf c) { errr res; @@ -2105,15 +2105,15 @@ int nc = Term->char_blank; byte *scr_aa; - char *scr_cc; + glyf *scr_cc; #ifdef USE_TRANSPARENCY byte *scr_taa; - char *scr_tcc; + glyf *scr_tcc; #ifdef USE_EGO_GRAPHICS byte *scr_eaa; - char *scr_ecc; + glyf *scr_ecc; #endif /* USE_EGO_GRAPHICS */ #endif /* USE_TRANSPARENCY */ @@ -2137,6 +2137,7 @@ #endif #endif /* USE_TRANSPARENCY */ + // TODO: byte cast is bad, why do we check 255? if (n > 0 && (byte)scr_cc[x] == 255 && scr_aa[x] == 255) { x--; @@ -2147,7 +2148,7 @@ for (i = 0; i < n; i++, x++) { int oa = scr_aa[x]; - int oc = scr_cc[x]; + glyf oc = scr_cc[x]; /* Hack -- Ignore "non-changes" */ if ((oa == na) && (oc == nc)) continue; @@ -2215,15 +2216,15 @@ for (y = 0; y < h; y++) { byte *scr_aa = Term->scr->a[y]; - char *scr_cc = Term->scr->c[y]; + glyf *scr_cc = Term->scr->c[y]; #ifdef USE_TRANSPARENCY byte *scr_taa = Term->scr->ta[y]; - char *scr_tcc = Term->scr->tc[y]; + glyf *scr_tcc = Term->scr->tc[y]; #ifdef USE_EGO_GRAPHICS byte *scr_eaa = Term->scr->ea[y]; - char *scr_ecc = Term->scr->ec[y]; + glyf *scr_ecc = Term->scr->ec[y]; #endif /* USE_EGO_GRAPHICS */ #endif /* USE_TRANSPARENCY */ @@ -2298,7 +2299,7 @@ { int i, j; - char *c_ptr; + glyf *c_ptr; #if 0 // DGDGDGDG /* Pat */ @@ -2399,7 +2400,7 @@ * Note that this refers to what will be on the window after the * next call to "Term_fresh()". It may or may not already be there. */ -errr Term_what(int x, int y, byte *a, char *c) +errr Term_what(int x, int y, byte *a, glyf *c) { int w = Term->wid; int h = Term->hgt; diff -Naur tome-231-src/src/z-term.h tome-231-src/src/z-term.h --- tome-231-src/src/z-term.h 2004-12-29 16:24:30.000000000 -0800 +++ tome-231-src/src/z-term.h 2005-04-07 04:48:42.000000000 -0700 @@ -39,24 +39,24 @@ byte cx, cy; byte **a; - char **c; + glyf **c; byte *va; - char *vc; + glyf *vc; #ifdef USE_TRANSPARENCY byte **ta; - char **tc; + glyf **tc; byte *vta; - char *vtc; + glyf *vtc; #ifdef USE_EGO_GRAPHICS byte **ea; - char **ec; + glyf **ec; byte *vea; - char *vec; + glyf *vec; #endif /* USE_EGO_GRAPHICS */ #endif /* USE_TRANSPARENCY */ @@ -226,18 +226,18 @@ errr (*wipe_hook)(int x, int y, int n); - errr (*text_hook)(int x, int y, int n, byte a, cptr s); + errr (*text_hook)(int x, int y, int n, byte a, const glyf *s); void (*resize_hook)(void); #ifdef USE_TRANSPARENCY #ifdef USE_EGO_GRAPHICS - errr (*pict_hook)(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp, const byte *eap, const char *ecp); + errr (*pict_hook)(int x, int y, int n, const byte *ap, const glyf *cp, const byte *tap, const glyf *tcp, const byte *eap, const glyf *ecp); #else /* USE_EGO_GRAPHICS */ - errr (*pict_hook)(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp); + errr (*pict_hook)(int x, int y, int n, const byte *ap, const glyf *cp, const byte *tap, const glyf *tcp); #endif /* USE_EGO_GRAPHICS */ #else /* USE_TRANSPARENCY */ - errr (*pict_hook)(int x, int y, int n, const byte *ap, const char *cp); + errr (*pict_hook)(int x, int y, int n, const byte *ap, const glyf *cp); #endif /* USE_TRANSPARENCY */ }; @@ -305,18 +305,18 @@ #ifdef USE_TRANSPARENCY #ifdef USE_EGO_GRAPHICS -extern void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc, byte ea, char ec); +extern void Term_queue_char(int x, int y, byte a, glyf c, byte ta, glyf tc, byte ea, glyf ec); -extern void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc, byte *ea, char *ec); +extern void Term_queue_line(int x, int y, int n, byte *a, glyf *c, byte *ta, glyf *tc, byte *ea, glyf *ec); #else /* USE_EGO_GRAPHICS */ -extern void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc); +extern void Term_queue_char(int x, int y, byte a, glyf c, byte ta, glyf tc); -extern void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc); +extern void Term_queue_line(int x, int y, int n, byte *a, glyf *c, byte *ta, glyf *tc); #endif /* USE_EGO_GRAPHICS */ #else /* USE_TRANSPARENCY */ -extern void Term_queue_char(int x, int y, byte a, char c); +extern void Term_queue_char(int x, int y, byte a, glyf c); -extern void Term_queue_line(int x, int y, int n, byte *a, char *c); +extern void Term_queue_line(int x, int y, int n, byte *a, glyf *c); #endif /* USE_TRANSPARENCY */ extern void Term_queue_chars(int x, int y, int n, byte a, cptr s); @@ -324,10 +324,10 @@ extern errr Term_fresh(void); extern errr Term_set_cursor(int v); extern errr Term_gotoxy(int x, int y); -extern errr Term_draw(int x, int y, byte a, char c); -extern errr Term_addch(byte a, char c); +extern errr Term_draw(int x, int y, byte a, glyf c); +extern errr Term_addch(byte a, glyf c); extern errr Term_addstr(int n, byte a, cptr s); -extern errr Term_putch(int x, int y, byte a, char c); +extern errr Term_putch(int x, int y, byte a, glyf c); extern errr Term_putstr(int x, int y, int n, byte a, cptr s); extern errr Term_erase(int x, int y, int n); extern errr Term_clear(void); @@ -337,7 +337,7 @@ extern errr Term_get_cursor(int *v); extern errr Term_get_size(int *w, int *h); extern errr Term_locate(int *x, int *y); -extern errr Term_what(int x, int y, byte *a, char *c); +extern errr Term_what(int x, int y, byte *a, glyf *c); extern errr Term_flush(void); extern errr Term_keypress(int k);