OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / z-term.c
index 8980349..76a167e 100644 (file)
@@ -297,22 +297,22 @@ term *Term = NULL;
 /*
  * Nuke a term_win (see below)
  */
-static errr term_win_nuke(term_win *s, int w, int h)
+static errr term_win_nuke(term_win *s, TERM_LEN w, TERM_LEN h)
 {
        /* Free the window access arrays */
-       C_KILL(s->a, h, byte*);
+       C_KILL(s->a, h, TERM_COLOR*);
        C_KILL(s->c, h, char*);
 
        /* Free the window content arrays */
-       C_KILL(s->va, h * w, byte);
+       C_KILL(s->va, h * w, TERM_COLOR);
        C_KILL(s->vc, h * w, char);
 
        /* Free the terrain access arrays */
-       C_KILL(s->ta, h, byte*);
+       C_KILL(s->ta, h, TERM_COLOR*);
        C_KILL(s->tc, h, char*);
 
        /* Free the terrain content arrays */
-       C_KILL(s->vta, h * w, byte);
+       C_KILL(s->vta, h * w, TERM_COLOR);
        C_KILL(s->vtc, h * w, char);
 
        /* Success */
@@ -323,24 +323,24 @@ static errr term_win_nuke(term_win *s, int w, int h)
 /*
  * Initialize a "term_win" (using the given window size)
  */
-static errr term_win_init(term_win *s, int w, int h)
+static errr term_win_init(term_win *s, TERM_LEN w, TERM_LEN h)
 {
        TERM_LEN y;
 
        /* Make the window access arrays */
-       C_MAKE(s->a, h, byte*);
+       C_MAKE(s->a, h, TERM_COLOR*);
        C_MAKE(s->c, h, char*);
 
        /* Make the window content arrays */
-       C_MAKE(s->va, h * w, byte);
+       C_MAKE(s->va, h * w, TERM_COLOR);
        C_MAKE(s->vc, h * w, char);
 
        /* Make the terrain access arrays */
-       C_MAKE(s->ta, h, byte*);
+       C_MAKE(s->ta, h, TERM_COLOR*);
        C_MAKE(s->tc, h, char*);
 
        /* Make the terrain content arrays */
-       C_MAKE(s->vta, h * w, byte);
+       C_MAKE(s->vta, h * w, TERM_COLOR);
        C_MAKE(s->vtc, h * w, char);
 
 
@@ -362,23 +362,23 @@ static errr term_win_init(term_win *s, int w, int h)
 /*
  * Copy a "term_win" from another
  */
-static errr term_win_copy(term_win *s, term_win *f, int w, int h)
+static errr term_win_copy(term_win *s, term_win *f, TERM_LEN w, TERM_LEN h)
 {
        TERM_LEN x, y;
 
        /* Copy contents */
        for (y = 0; y < h; y++)
        {
-               byte *f_aa = f->a[y];
+               TERM_COLOR *f_aa = f->a[y];
                char *f_cc = f->c[y];
 
-               byte *s_aa = s->a[y];
+               TERM_COLOR *s_aa = s->a[y];
                char *s_cc = s->c[y];
 
-               byte *f_taa = f->ta[y];
+               TERM_COLOR *f_taa = f->ta[y];
                char *f_tcc = f->tc[y];
 
-               byte *s_taa = s->ta[y];
+               TERM_COLOR *s_taa = s->ta[y];
                char *s_tcc = s->tc[y];
 
                for (x = 0; x < w; x++)
@@ -444,7 +444,6 @@ static errr Term_curs_hack(TERM_LEN x, TERM_LEN y)
        (void)x;
        (void)y;
 
-       /* Oops */
        return (-1);
 }
 
@@ -466,14 +465,13 @@ static errr Term_wipe_hack(TERM_LEN x, TERM_LEN y, int n)
        (void)y;
        (void)n;
 
-       /* Oops */
        return (-1);
 }
 
 /*
  * Hack -- fake hook for "Term_text()" (see above)
  */
-static errr Term_text_hack(TERM_LEN x, TERM_LEN y, int n, byte a, cptr cp)
+static errr Term_text_hack(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr cp)
 {
        /* Unused */
        (void)x;
@@ -482,14 +480,13 @@ static errr Term_text_hack(TERM_LEN x, TERM_LEN y, int n, byte a, cptr cp)
        (void)a;
        (void)cp;
 
-       /* Oops */
        return (-1);
 }
 
 /*
  * Hack -- fake hook for "Term_pict()" (see above)
  */
-static errr Term_pict_hack(TERM_LEN x, TERM_LEN y, int n, const byte *ap, cptr cp, const byte *tap, cptr tcp)
+static errr Term_pict_hack(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, concptr cp, const TERM_COLOR *tap, concptr tcp)
 {
        /* Unused */
        (void)x;
@@ -500,7 +497,6 @@ static errr Term_pict_hack(TERM_LEN x, TERM_LEN y, int n, const byte *ap, cptr c
        (void)tap;
        (void)tcp;
 
-       /* Oops */
        return (-1);
 }
 
@@ -511,17 +507,16 @@ static errr Term_pict_hack(TERM_LEN x, TERM_LEN y, int n, const byte *ap, cptr c
 
 /*
  * Mentally draw an attr/char at a given location
- *
  * Assumes given location and values are valid.
  */
-void Term_queue_char(TERM_LEN x, TERM_LEN y, byte a, char c, byte ta, char tc)
+void Term_queue_char(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc)
 {
        term_win *scrn = Term->scr; 
        
-       byte *scr_aa = &scrn->a[y][x];
+       TERM_COLOR *scr_aa = &scrn->a[y][x];
        char *scr_cc = &scrn->c[y][x];
 
-       byte *scr_taa = &scrn->ta[y][x];
+       TERM_COLOR *scr_taa = &scrn->ta[y][x];
        char *scr_tcc = &scrn->tc[y][x];
 
        /* Hack -- Ignore non-changes */
@@ -555,14 +550,11 @@ void Term_queue_char(TERM_LEN x, TERM_LEN y, byte a, char c, byte ta, char tc)
 
 /*
  * Bigtile version of Term_queue_char().
- *
  * If use_bigtile is FALSE, simply call Term_queue_char().
- *
  * Otherwise, mentally draw a pair of attr/char at a given location.
- *
  * Assumes given location and values are valid.
  */
-void Term_queue_bigchar(TERM_LEN x, TERM_LEN y, byte a, char c, byte ta, char tc)
+void Term_queue_bigchar(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc)
 {
 
 #ifdef JP
@@ -644,17 +636,17 @@ void Term_queue_bigchar(TERM_LEN x, TERM_LEN y, byte a, char c, byte ta, char tc
  * This function is designed to be fast, with no consistancy checking.
  * It is used to update the map in the game.
  */
-void Term_queue_line(TERM_LEN x, TERM_LEN y, int n, byte *a, char *c, byte *ta, char *tc)
+void Term_queue_line(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR *a, char *c, TERM_COLOR *ta, char *tc)
 {
        term_win *scrn = Term->scr;
 
        TERM_LEN x1 = -1;
        TERM_LEN x2 = -1;
 
-       byte *scr_aa = &scrn->a[y][x];
+       TERM_COLOR *scr_aa = &scrn->a[y][x];
        char *scr_cc = &scrn->c[y][x];
 
-       byte *scr_taa = &scrn->ta[y][x];
+       TERM_COLOR *scr_taa = &scrn->ta[y][x];
        char *scr_tcc = &scrn->tc[y][x];
 
        while (n--)
@@ -715,20 +707,20 @@ void Term_queue_line(TERM_LEN x, TERM_LEN y, int n, byte *a, char *c, byte *ta,
  * a valid location, so the first "n" characters of "s" can all be added
  * starting at (x,y) without causing any illegal operations.
  */
-void Term_queue_chars(TERM_LEN x, TERM_LEN y, int n, byte a, cptr s)
+void Term_queue_chars(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s)
 {
        TERM_LEN x1 = -1, x2 = -1;
 
-       byte *scr_aa = Term->scr->a[y];
+       TERM_COLOR *scr_aa = Term->scr->a[y];
 #ifdef JP
        char *scr_cc = Term->scr->c[y];
 
-       byte *scr_taa = Term->scr->ta[y];
+       TERM_COLOR *scr_taa = Term->scr->ta[y];
        char *scr_tcc = Term->scr->tc[y];
 #else
        char *scr_cc = Term->scr->c[y];
 
-       byte *scr_taa = Term->scr->ta[y];
+       TERM_COLOR *scr_taa = Term->scr->ta[y];
        char *scr_tcc = Term->scr->tc[y];
 #endif
 
@@ -782,10 +774,10 @@ void Term_queue_chars(TERM_LEN x, TERM_LEN y, int n, byte a, cptr s)
                else
                {
 #endif
-               byte oa = scr_aa[x];
+               TERM_COLOR oa = scr_aa[x];
                char oc = scr_cc[x];
 
-               byte ota = scr_taa[x];
+               TERM_COLOR ota = scr_taa[x];
                char otc = scr_tcc[x];
 
                /* Hack -- Ignore non-changes */
@@ -848,39 +840,39 @@ void Term_queue_chars(TERM_LEN x, TERM_LEN y, int n, byte a, cptr s)
  *
  * Display text using "Term_pict()"
  */
-static void Term_fresh_row_pict(TERM_LEN y, int x1, int x2)
+static void Term_fresh_row_pict(TERM_LEN y, TERM_LEN x1, TERM_LEN x2)
 {
        TERM_LEN x;
 
-       byte *old_aa = Term->old->a[y];
+       TERM_COLOR *old_aa = Term->old->a[y];
        char *old_cc = Term->old->c[y];
 
-       byte *scr_aa = Term->scr->a[y];
+       TERM_COLOR *scr_aa = Term->scr->a[y];
        char *scr_cc = Term->scr->c[y];
 
-       byte *old_taa = Term->old->ta[y];
+       TERM_COLOR *old_taa = Term->old->ta[y];
        char *old_tcc = Term->old->tc[y];
 
-       byte *scr_taa = Term->scr->ta[y];
+       TERM_COLOR *scr_taa = Term->scr->ta[y];
        char *scr_tcc = Term->scr->tc[y];
 
-       byte ota;
+       TERM_COLOR ota;
        char otc;
 
-       byte nta;
+       TERM_COLOR nta;
        char ntc;
 
 
        /* Pending length */
-       int fn = 0;
+       TERM_LEN fn = 0;
 
        /* Pending start */
-       int fx = 0;
+       TERM_LEN fx = 0;
 
-       byte oa;
+       TERM_COLOR oa;
        char oc;
 
-       byte na;
+       TERM_COLOR na;
        char nc;
 
 #ifdef JP
@@ -936,7 +928,7 @@ static void Term_fresh_row_pict(TERM_LEN y, int x1, int x2)
                        {
                                /* Draw pending attr/char pairs */
                                (void)((*Term->pict_hook)(fx, y, fn,
-                                      &scr_aa[fx], &scr_cc[fx],&scr_taa[fx], &scr_tcc[fx]));
+                                      &scr_aa[fx], &scr_cc[fx], &scr_taa[fx], &scr_tcc[fx]));
 
                                /* Forget */
                                fn = 0;
@@ -986,20 +978,20 @@ static void Term_fresh_row_both(TERM_LEN y, int x1, int x2)
 {
        TERM_LEN x;
 
-       byte *old_aa = Term->old->a[y];
+       TERM_COLOR *old_aa = Term->old->a[y];
        char *old_cc = Term->old->c[y];
 
-       byte *scr_aa = Term->scr->a[y];
+       TERM_COLOR *scr_aa = Term->scr->a[y];
        char *scr_cc = Term->scr->c[y];
 
-       byte *old_taa = Term->old->ta[y];
+       TERM_COLOR *old_taa = Term->old->ta[y];
        char *old_tcc = Term->old->tc[y];
-       byte *scr_taa = Term->scr->ta[y];
+       TERM_COLOR *scr_taa = Term->scr->ta[y];
        char *scr_tcc = Term->scr->tc[y];
 
-       byte ota;
+       TERM_COLOR ota;
        char otc;
-       byte nta;
+       TERM_COLOR nta;
        char ntc;
 
        /* The "always_text" flag */
@@ -1014,10 +1006,10 @@ static void Term_fresh_row_both(TERM_LEN y, int x1, int x2)
        /* Pending attr */
        byte fa = Term->attr_blank;
 
-       byte oa;
+       TERM_COLOR oa;
        char oc;
 
-       byte na;
+       TERM_COLOR na;
        char nc;
 
 #ifdef JP
@@ -1203,14 +1195,14 @@ static void Term_fresh_row_both(TERM_LEN y, int x1, int x2)
  *
  * Display text using "Term_text()" and "Term_wipe()"
  */
-static void Term_fresh_row_text(TERM_LEN y, int x1, int x2)
+static void Term_fresh_row_text(TERM_LEN y, TERM_LEN x1, TERM_LEN x2)
 {
        TERM_LEN x;
 
-       byte *old_aa = Term->old->a[y];
+       TERM_COLOR *old_aa = Term->old->a[y];
        char *old_cc = Term->old->c[y];
 
-       byte *scr_aa = Term->scr->a[y];
+       TERM_COLOR *scr_aa = Term->scr->a[y];
        char *scr_cc = Term->scr->c[y];
 
        /* The "always_text" flag */
@@ -1225,10 +1217,10 @@ static void Term_fresh_row_text(TERM_LEN y, int x1, int x2)
        /* Pending attr */
        byte fa = Term->attr_blank;
 
-       byte oa;
+       TERM_COLOR oa;
        char oc;
 
-       byte na;
+       TERM_COLOR na;
        char nc;
 
 #ifdef JP
@@ -1476,7 +1468,7 @@ static void Term_fresh_row_text(TERM_LEN y, int x1, int x2)
  * On systems with a "soft" cursor, we must explicitly erase the cursor
  * before flushing the output, if needed, to prevent a "jumpy" refresh.
  * The actual method for this is horrible, but there is very little that
- * we can do to simplify it efficiently.  XXX XXX XXX
+ * we can do to simplify it efficiently.  
  *
  * On systems with a "hard" cursor, we will "hide" the cursor before
  * flushing the output, if needed, to avoid a "flickery" refresh.  It
@@ -1540,10 +1532,10 @@ errr Term_fresh(void)
                /* Wipe each row */
                for (y = 0; y < h; y++)
                {
-                       byte *aa = old->a[y];
+                       TERM_COLOR *aa = old->a[y];
                        char *cc = old->c[y];
 
-                       byte *taa = old->ta[y];
+                       TERM_COLOR *taa = old->ta[y];
                        char *tcc = old->tc[y];
 
 
@@ -1582,16 +1574,16 @@ errr Term_fresh(void)
                if (!old->cu && old->cv)
                {
                        int csize = 1;
-                       int tx = old->cx;
-                       int ty = old->cy;
+                       TERM_LEN tx = old->cx;
+                       TERM_LEN ty = old->cy;
 
-                       byte *old_aa = old->a[ty];
+                       TERM_COLOR *old_aa = old->a[ty];
                        char *old_cc = old->c[ty];
 
-                       byte *old_taa = old->ta[ty];
+                       TERM_COLOR *old_taa = old->ta[ty];
                        char *old_tcc = old->tc[ty];
 
-                       byte ota = old_taa[tx];
+                       TERM_COLOR ota = old_taa[tx];
                        char otc = old_tcc[tx];
 
 #ifdef JP
@@ -1835,7 +1827,7 @@ errr Term_gotoxy(TERM_LEN x, TERM_LEN y)
  * Do not change the cursor position
  * No visual changes until "Term_fresh()".
  */
-errr Term_draw(TERM_LEN x, TERM_LEN y, byte a, char c)
+errr Term_draw(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c)
 {
        int w = Term->wid;
        int h = Term->hgt;
@@ -1871,9 +1863,9 @@ errr Term_draw(TERM_LEN x, TERM_LEN y, byte a, char c)
  * positive value, future calls to either function will
  * return negative ones.
  */
-errr Term_addch(byte a, char c)
+errr Term_addch(TERM_COLOR a, char c)
 {
-       int w = Term->wid;
+       TERM_LEN w = Term->wid;
 
        /* Handle "unusable" cursor */
        if (Term->scr->cu) return (-1);
@@ -1906,7 +1898,7 @@ errr Term_addch(byte a, char c)
  * Otherwise, queue a pair of attr/char for display at the current
  * cursor location, and advance the cursor to the right by two.
  */
-errr Term_add_bigch(byte a, char c)
+errr Term_add_bigch(TERM_COLOR a, char c)
 {
        if (!use_bigtile) return Term_addch(a, c);
 
@@ -1952,12 +1944,10 @@ errr Term_add_bigch(byte a, char c)
  * positive value, future calls to either function will
  * return negative ones.
  */
-errr Term_addstr(int n, byte a, cptr s)
+errr Term_addstr(int n, TERM_COLOR a, concptr s)
 {
        int k;
-
-       int w = Term->wid;
-
+       TERM_LEN w = Term->wid;
        errr res = 0;
 
        /* Handle "unusable" cursor */
@@ -1989,7 +1979,7 @@ errr Term_addstr(int n, byte a, cptr s)
 /*
  * Move to a location and, using an attr, add a char
  */
-errr Term_putch(TERM_LEN x, TERM_LEN y, byte a, char c)
+errr Term_putch(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c)
 {
        errr res;
 
@@ -2007,7 +1997,7 @@ errr Term_putch(TERM_LEN x, TERM_LEN y, byte a, char c)
 /*
  * Move to a location and, using an attr, add a string
  */
-errr Term_putstr(TERM_LEN x, TERM_LEN y, int n, byte a, cptr s)
+errr Term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s)
 {
        errr res;
 
@@ -2025,7 +2015,7 @@ errr Term_putstr(TERM_LEN x, TERM_LEN y, int n, byte a, cptr s)
 /*
  * Move to a location and, using an attr, add a string vertically
  */
-errr Term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, cptr s)
+errr Term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, concptr s)
 {
        errr res;
        int i;
@@ -2070,10 +2060,10 @@ errr Term_erase(TERM_LEN x, TERM_LEN y, int n)
        int na = Term->attr_blank;
        int nc = Term->char_blank;
 
-       byte *scr_aa;
+       TERM_COLOR *scr_aa;
        char *scr_cc;
 
-       byte *scr_taa;
+       TERM_COLOR *scr_taa;
        char *scr_tcc;
 
        /* Place cursor */
@@ -2164,10 +2154,10 @@ errr Term_clear(void)
 {
        TERM_LEN x, y;
 
-       int w = Term->wid;
-       int h = Term->hgt;
+       TERM_LEN w = Term->wid;
+       TERM_LEN h = Term->hgt;
 
-       byte na = Term->attr_blank;
+       TERM_COLOR na = Term->attr_blank;
        char nc = Term->char_blank;
 
        /* Cursor usable */
@@ -2179,10 +2169,10 @@ errr Term_clear(void)
        /* Wipe each row */
        for (y = 0; y < h; y++)
        {
-               byte *scr_aa = Term->scr->a[y];
+               TERM_COLOR *scr_aa = Term->scr->a[y];
                char *scr_cc = Term->scr->c[y];
 
-               byte *scr_taa = Term->scr->ta[y];
+               TERM_COLOR *scr_taa = Term->scr->ta[y];
                char *scr_tcc = Term->scr->tc[y];
 
                /* Wipe each column */
@@ -2335,7 +2325,7 @@ errr Term_get_size(TERM_LEN *w, TERM_LEN *h)
 /*
  * Extract the current cursor location
  */
-errr Term_locate(int *x, int *y)
+errr Term_locate(TERM_LEN *x, TERM_LEN *y)
 {
        /* Access the cursor */
        (*x) = Term->scr->cx;
@@ -2354,10 +2344,10 @@ errr Term_locate(int *x, int *y)
  * 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(TERM_LEN x, TERM_LEN y, byte *a, char *c)
+errr Term_what(TERM_LEN x, TERM_LEN y, TERM_COLOR *a, char *c)
 {
-       int w = Term->wid;
-       int h = Term->hgt;
+       TERM_LEN w = Term->wid;
+       TERM_LEN h = Term->hgt;
 
        /* Verify location */
        if ((x < 0) || (x >= w)) return (-1);
@@ -2437,11 +2427,6 @@ errr Term_key_push(int k)
        /* Success (unless overflow) */
        if (Term->key_head != Term->key_tail) return (0);
 
-#if 0
-       /* Hack -- Forget the oldest key */
-       if (++Term->key_tail == Term->key_size) Term->key_tail = 0;
-#endif
-
        /* Problem */
        return (1);
 }
@@ -2523,8 +2508,8 @@ errr Term_inkey(char *ch, bool wait, bool take)
  */
 errr Term_save(void)
 {
-       int w = Term->wid;
-       int h = Term->hgt;
+       TERM_LEN w = Term->wid;
+       TERM_LEN h = Term->hgt;
 
        /* Create */
        if (!Term->mem)
@@ -2553,8 +2538,8 @@ errr Term_load(void)
 {
        TERM_LEN y;
 
-       int w = Term->wid;
-       int h = Term->hgt;
+       TERM_LEN w = Term->wid;
+       TERM_LEN h = Term->hgt;
 
        /* Create */
        if (!Term->mem)
@@ -2593,8 +2578,8 @@ errr Term_exchange(void)
 {
        TERM_LEN y;
 
-       int w = Term->wid;
-       int h = Term->hgt;
+       TERM_LEN w = Term->wid;
+       TERM_LEN h = Term->hgt;
 
        term_win *exchanger;
 
@@ -2635,14 +2620,14 @@ errr Term_exchange(void)
 /*
  * React to a new physical window size.
  */
-errr Term_resize(int w, int h)
+errr Term_resize(TERM_LEN w, TERM_LEN h)
 {
        int i;
 
-       int wid, hgt;
+       TERM_LEN wid, hgt;
 
-       byte *hold_x1;
-       byte *hold_x2;
+       TERM_LEN *hold_x1;
+       TERM_LEN *hold_x2;
 
        term_win *hold_old;
        term_win *hold_scr;
@@ -2683,8 +2668,8 @@ errr Term_resize(int w, int h)
        hold_tmp = Term->tmp;
 
        /* Create new scanners */
-       C_MAKE(Term->x1, h, byte);
-       C_MAKE(Term->x2, h, byte);
+       C_MAKE(Term->x1, h, TERM_LEN);
+       C_MAKE(Term->x2, h, TERM_LEN);
 
        /* Create new window */
        MAKE(Term->old, term_win);
@@ -2731,8 +2716,8 @@ errr Term_resize(int w, int h)
        }
 
        /* Free some arrays */
-       C_KILL(hold_x1, Term->hgt, byte);
-       C_KILL(hold_x2, Term->hgt, byte);
+       C_KILL(hold_x1, Term->hgt, TERM_LEN);
+       C_KILL(hold_x2, Term->hgt, TERM_LEN);
 
        /* Nuke */
        term_win_nuke(hold_old, Term->wid, Term->hgt);
@@ -2783,8 +2768,8 @@ errr Term_resize(int w, int h)
        }
 
        /* Save new size */
-       Term->wid = (byte_hack)w;
-       Term->hgt = (byte_hack)h;
+       Term->wid = w;
+       Term->hgt = h;
 
        /* Force "total erase" */
        Term->total_erase = TRUE;
@@ -2860,8 +2845,8 @@ errr Term_activate(term *t)
  */
 errr term_nuke(term *t)
 {
-       int w = t->wid;
-       int h = t->hgt;
+       TERM_LEN w = t->wid;
+       TERM_LEN h = t->hgt;
 
 
        /* Hack -- Call the special "nuke" hook */
@@ -2911,8 +2896,8 @@ errr term_nuke(term *t)
        }
 
        /* Free some arrays */
-       C_KILL(t->x1, h, byte);
-       C_KILL(t->x2, h, byte);
+       C_KILL(t->x1, h, TERM_LEN);
+       C_KILL(t->x2, h, TERM_LEN);
 
        /* Free the input queue */
        C_KILL(t->key_queue, t->key_size, char);
@@ -2928,7 +2913,7 @@ errr term_nuke(term *t)
  * By default, the cursor starts out "invisible"
  * By default, we "erase" using "black spaces"
  */
-errr term_init(term *t, int w, int h, int k)
+errr term_init(term *t, TERM_LEN w, TERM_LEN h, int k)
 {
        TERM_LEN y;
 
@@ -2948,12 +2933,12 @@ errr term_init(term *t, int w, int h, int k)
 
 
        /* Save the size */
-       t->wid = (byte_hack)w;
-       t->hgt = (byte_hack)h;
+       t->wid = w;
+       t->hgt = h;
 
        /* Allocate change arrays */
-       C_MAKE(t->x1, h, byte);
-       C_MAKE(t->x2, h, byte);
+       C_MAKE(t->x1, h, TERM_LEN);
+       C_MAKE(t->x2, h, TERM_LEN);
 
 
        /* Allocate "displayed" */