Fixed inconsistent types in src/sdl and fixed to src/common/frotz.h
authorDavid Griffith <dave@661.org>
Thu, 20 Apr 2023 05:44:42 +0000 (22:44 -0700)
committerDavid Griffith <dave@661.org>
Thu, 27 Apr 2023 18:47:20 +0000 (11:47 -0700)
Since before the SDL interface was integrated with this Frotz package,
it has been inconsistent with its delaration and use of three unsigned
variables for communicating with the Frotz Core.  These are zbyte
(8-bit), zword (16-bit), and zlong (32-bit).  Somehow the SDL interface
worked fine with GCC versions 10 and earlier, but no longer.  I probably
should have fixed these when doing the integrating.

At first the changes post GCC 10 manifested in a build failure.  I made
a couple changes to src/sdl/sf_frotz.h from line 15 to 18 to get it to
compile.  I don't remember what they were.  This resulted in a black
column being inserted after every column in the sfrotz window.  After
someone pointed out to me that I was attempting to do 32-bit operations
in a 64-bit variable, the problem and solution became clear.

Now the byte, word, and ulong usage in the SDL interface has been
replaced with zbyte, zword, and zlong as defined in src/common/frotz.h.

src/common/frotz.h
src/sdl/sf_font3.c
src/sdl/sf_fonts.c
src/sdl/sf_frotz.h
src/sdl/sf_ftype.c
src/sdl/sf_images.c
src/sdl/sf_osfdlg.c
src/sdl/sf_resource.c
src/sdl/sf_sound.c
src/sdl/sf_util.c
src/sdl/sf_video.c

index d0a052ff0537f2e893288cf43e73bb0693ab4cf8..112623cdafeae4983394a58200c0d71a156018ed 100644 (file)
@@ -69,6 +69,7 @@ typedef int bool;
 /* For everything */
 /******************************************************************************/
 #include <stdio.h>
+#include <stdint.h>
 
 #include "defs.h"
 #include "hash.h"
@@ -101,10 +102,9 @@ typedef int bool;
 #define PATH_SEPARATOR '/'
 #endif
 
-/* typedef unsigned short zbyte; */
-typedef unsigned char zbyte;
-typedef unsigned short zword;
-typedef unsigned long zlong;
+typedef uint8_t zbyte;
+typedef uint16_t zword;
+typedef uint32_t zlong;
 
 #ifndef USE_UTF8
 typedef unsigned char zchar;
index ddabd44fa9ad71f0c4742fcb6413c4d8f6f602b5..9d7f98804df8c57b6c863c257a1efe7a1e9b3e54 100644 (file)
@@ -22,7 +22,7 @@
 #include "sf_frotz.h"
 #include <string.h>
 
-static byte Zfont3[] = {
+static zbyte Zfont3[] = {
 /* 32*/        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 /* 33*/        0x00,0x00,0x20,0x60,0xfe,0x60,0x20,0x00,
 /* 34*/        0x00,0x00,0x08,0x0c,0xfe,0x0c,0x08,0x00,
@@ -121,10 +121,10 @@ static byte Zfont3[] = {
 
 /* glyph buffer */
 static struct {
-       byte dx;
-       byte w, h;
+       zbyte dx;
+       zbyte w, h;
        char xof, yof;
-       byte bitmap[16];
+       zbyte bitmap[16];
 } myglyph = {8,8,8,0,-2};
 
 static void nodestroy(SFONT *s){}
@@ -133,15 +133,15 @@ static int myascent(SFONT *s){ return 6;}
 static int mydescent(SFONT *s){ return 2;}
 static int myminchar(SFONT *s){ return 32;}
 static int mymaxchar(SFONT *s){ return 126;}
-static int myhasglyph(SFONT *s, word c, int allowdef)
+static int myhasglyph(SFONT *s, zword c, int allowdef)
 {
        return (c >= 32 && c <= 126) || allowdef;
 }
 
 
-static SF_glyph * mygetglyph(SFONT *s, word c, int allowdef)
+static SF_glyph * mygetglyph(SFONT *s, zword c, int allowdef)
 {
-       byte *src;
+       zbyte *src;
        if (c < 32 || c > 126) {
                if (!allowdef)
                        return NULL;
@@ -173,9 +173,9 @@ SFONT * SF_font3 = &myfont3;
 static int myheight2(SFONT *s){ return 16;}
 static int myascent2(SFONT *s){ return 14;}
 static int mydescent2(SFONT *s){ return 2;}
-static SF_glyph * mygetglyph2(SFONT *s, word c, int allowdef)
+static SF_glyph * mygetglyph2(SFONT *s, zword c, int allowdef)
 {
-       byte *src, *dst; int i;
+       zbyte *src, *dst; int i;
        if (c < 32 || c > 126) {
                if (!allowdef)
                        return NULL;
index f52648377d2a8c98ad3bb9f5b78e3e154c92e08b..a1368aba178b4bdb869cba95c920b0cf39b6cce3 100644 (file)
@@ -30,8 +30,8 @@
 
 typedef struct {
        int refcount;
-       word minchar, maxchar, defchar;
-       byte ascent, descent;
+       zword minchar, maxchar, defchar;
+       zbyte ascent, descent;
        int glyphs[0];          /* offsets to glyphs from start of rec */
 } SF_bdffont;
 
@@ -64,7 +64,7 @@ static int hexd(char c)
 }
 
 
-static void gethex(char *p, byte * dst, int n)
+static void gethex(char *p, zbyte * dst, int n)
 {
        while (n--) {
                *dst++ = 16 * hexd(p[0]) + hexd(p[1]);
@@ -78,7 +78,7 @@ static void gethex(char *p, byte * dst, int n)
 static SF_bdffont *sBDXload(FILE * f, int *err, int *size, int MAXCHAR)
 {
        int totb, i, k = 0, wh[4];
-       byte *po, *pbeg;
+       zbyte *po, *pbeg;
        char *p, *q;
        char *fontname = "", *copyright = "unknown";
        int fngot = 0, cpgot = 0;
@@ -197,8 +197,8 @@ static SF_bdffont *sBDXload(FILE * f, int *err, int *size, int MAXCHAR)
        font->defchar = defchar;
        font->ascent = ascent;
        font->descent = descent;
-       pbeg = (byte *) font;
-       po = (byte *) (&(font->glyphs[maxch - minch + 1]));
+       pbeg = (zbyte *) font;
+       po = (zbyte *) (&(font->glyphs[maxch - minch + 1]));
        k = strlen(fontname) + 1;
        memmove(po, fontname, k);
        po += k;
@@ -259,7 +259,7 @@ static SF_bdffont *sBDXload(FILE * f, int *err, int *size, int MAXCHAR)
                                bg->h = h = wh[1];
                                bg->xof = wh[2];
                                bg->yof = wh[3];
-                               po = (byte *) (&(bg->bitmap[0]));
+                               po = (zbyte *) (&(bg->bitmap[0]));
                                for (j = 0; j < h; j++) {
                                        fgets(s, 1024, f);
                                        if (feof(f))
@@ -336,7 +336,7 @@ static int bmaxchar(SFONT * s)
        return 0;
 }
 
-static SF_glyph *getglyph(SFONT * fo, word c, int allowdef)
+static SF_glyph *getglyph(SFONT * fo, zword c, int allowdef)
 {
        int m;
        SF_bdffont *b;
@@ -358,11 +358,11 @@ static SF_glyph *getglyph(SFONT * fo, word c, int allowdef)
                else
                        return NULL;
        }
-       return (SF_glyph *) (((byte *) b) + m);
+       return (SF_glyph *) (((zbyte *) b) + m);
 }
 
 
-static int hasglyph(SFONT * fo, word c, int allowdef)
+static int hasglyph(SFONT * fo, zword c, int allowdef)
 {
        return (getglyph(fo, c, allowdef) != NULL);
 }
@@ -854,7 +854,7 @@ SFONT *sf_VGA_SFONT;
 void sf_initfonts()
 {
        int i, j, size = 0;
-       byte *cfont, *bmp;
+       zbyte *cfont, *bmp;
        SF_glyph *g;
        SF_bdffont *norm, *emph, *bold, *bemp;
        SFONT *Norm, *Emph = NULL, *Bold = NULL, *Bemp = NULL;
@@ -877,13 +877,13 @@ void sf_initfonts()
                os_fatal("malloc() failure in initfonts()");
        memmove(emph, norm, size);
        /* emphasize (underline)... */
-       cfont = (byte *) emph;
+       cfont = (zbyte *) emph;
        for (i = norm->minchar; i <= norm->maxchar; i++) {
                int m = norm->glyphs[i - norm->minchar];
                if (!m)
                        continue;
                g = (SF_glyph *) (cfont + m);
-               bmp = (byte *) (&(g->bitmap[0]));
+               bmp = (zbyte *) (&(g->bitmap[0]));
                bmp[g->h - 2] = 0xff;
        }
        /* make a copy for bold */
@@ -895,14 +895,14 @@ void sf_initfonts()
                os_fatal("malloc() failure in initfonts()");
        memmove(bold, norm, size);
        /* boldify... */
-       cfont = (byte *) bold;
+       cfont = (zbyte *) bold;
        for (i = norm->minchar; i <= norm->maxchar; i++) {
                int h, m = norm->glyphs[i - norm->minchar];
                if (!m)
                        continue;
                g = (SF_glyph *) (cfont + m);
                h = g->h;
-               bmp = (byte *) (&(g->bitmap[0]));
+               bmp = (zbyte *) (&(g->bitmap[0]));
                for (j = 0; j < h; j++) {
                        int c = bmp[j];
                        bmp[j] = (c) | (c >> 1);
@@ -917,13 +917,13 @@ void sf_initfonts()
                os_fatal("malloc() failure in initfonts()");
        memmove(bemp, bold, size);
        /* emphasize (underline)... */
-       cfont = (byte *) bemp;
+       cfont = (zbyte *) bemp;
        for (i = norm->minchar; i <= norm->maxchar; i++) {
                int m = norm->glyphs[i - norm->minchar];
                if (!m)
                        continue;
                g = (SF_glyph *) (cfont + m);
-               bmp = (byte *) (&(g->bitmap[0]));
+               bmp = (zbyte *) (&(g->bitmap[0]));
                bmp[g->h - 2] = 0xff;
        }
 
index 8e1729d922d418b55caefe03e0711f1e0ceb3bb7..d29139c4ad8589306ad1fb9d57b84d91159862c5 100644 (file)
 #include "../blorb/blorb.h"
 
 #include <stdint.h>
-typedef uint8_t byte;
-typedef uint16_t word;
-#define ulong uint32_t
 
 typedef struct {
        bb_result_t bbres;
-       ulong type;
+       zlong type;
        FILE *file;
 } myresource;
 
@@ -54,7 +51,7 @@ bool sf_IsAdaptive(int picture);
 #endif
 
 /* this assumes RGBA with lsb = R */
-static inline ulong RGB5ToTrue(word w)
+static inline zlong RGB5ToTrue(zword w)
 {
        int _r = w & 0x001F;
        int _g = (w & 0x03E0) >> 5;
@@ -62,12 +59,12 @@ static inline ulong RGB5ToTrue(word w)
        _r = (_r << 3) | (_r >> 2);
        _g = (_g << 3) | (_g >> 2);
        _b = (_b << 3) | (_b >> 2);
-       return (ulong) (_r | (_g << 8) | (_b << 16));
+       return (zlong) (_r | (_g << 8) | (_b << 16));
 }
 
-static inline word TrueToRGB5(ulong u)
+static inline zword TrueToRGB5(zlong u)
 {
-       return (word) (((u >> 3) & 0x001f) | ((u >> 6) & 0x03e0) |
+       return (zword) (((u >> 3) & 0x001f) | ((u >> 6) & 0x03e0) |
                       ((u >> 9) & 0x7c00));
 }
 
@@ -81,10 +78,10 @@ extern bool m_tandy;
 extern int m_v6scale;
 extern double m_gfxScale_w;
 extern double m_gfxScale_h;
-extern ulong m_defaultFore;
-extern ulong m_defaultBack;
-extern ulong m_colours[11];
-extern ulong m_nonStdColours[NON_STD_COLS];
+extern zlong m_defaultFore;
+extern zlong m_defaultBack;
+extern zlong m_colours[11];
+extern zlong m_nonStdColours[NON_STD_COLS];
 extern int m_nonStdIndex;
 extern bool m_exitPause;
 extern bool m_lineInput;
@@ -117,8 +114,8 @@ int sf_load_resources(void);
 typedef struct {
        int number;     /* 0 means unallocated */
        int width, height;
-       byte *pixels;
-       ulong palette[16];
+       zbyte *pixels;
+       zlong palette[16];
        int palette_entries;
        int transparentcolor;
        bool adaptive;
@@ -137,10 +134,10 @@ void sf_flushtext();
 
 /* glyph */
 typedef struct {
-       byte dx;
-       byte w, h;
+       zbyte dx;
+       zbyte w, h;
        char xof, yof;
-       byte bitmap[0];
+       zbyte bitmap[0];
 } SF_glyph;
 
 typedef struct sfontstruct SFONT;
@@ -156,8 +153,8 @@ struct sfontstruct {
        int (*descent)(SFONT *);
        int (*minchar)(SFONT *);
        int (*maxchar)(SFONT *);
-       int (*hasglyph)(SFONT *, word, int);
-       SF_glyph *(*getglyph)(SFONT *, word, int);
+       int (*hasglyph)(SFONT *, zword, int);
+       SF_glyph *(*getglyph)(SFONT *, zword, int);
        int antialiased;
        void *data;
 };
@@ -168,7 +165,7 @@ typedef struct {
        int style, zfontnum;
        int cx, cy;             /* cursor position - 0 based */
        int oh;                 /* overhang */
-       unsigned long fore, back;
+       zlong fore, back;
        bool foreDefault, backDefault, backTransparent;
 } SF_textsetting;
 
@@ -182,7 +179,7 @@ int sf_charwidth(zword c, int *oh);
 
 void sf_writeglyph(SF_glyph * g);
 
-void sf_fillrect(unsigned long color, int x, int y, int w, int h);
+void sf_fillrect(zlong color, int x, int y, int w, int h);
 
 int sf_GetProfileInt(const char *sect, const char *id, int def);
 double sf_GetProfileDouble(const char *sect, const char *id, double def);
@@ -190,9 +187,9 @@ char *sf_GetProfileString(const char *sect, const char *id, char *def);
 
 void sf_readsettings();
 
-ulong sf_GetColour(int colour);
-ulong sf_GetDefaultColour(bool fore);
-int sf_GetColourIndex(ulong colour);
+zlong sf_GetColour(int colour);
+zlong sf_GetDefaultColour(bool fore);
+int sf_GetColourIndex(zlong colour);
 
 void sf_initvideo(int w, int h, int full);
 
@@ -221,11 +218,11 @@ enum { IDS_BLORB_GLULX, IDS_BLORB_NOEXEC, IDS_MORE, IDS_HIT_KEY_EXIT, IDS_TITLE,
 
 bool sf_IsInfocomV6(void);
 
-ulong sf_blend(int a, ulong s, ulong d);
+zlong sf_blend(int a, zlong s, zlong d);
 
 void sf_sleep(int millisecs);
 
-unsigned long sf_ticks(void);
+zlong sf_ticks(void);
 
 void sf_DrawInput(zchar * buffer, int pos, int ptx, int pty, int width,
                  bool cursor);
@@ -234,8 +231,8 @@ int sf_aiffwav(FILE * f, int foffs, void **wav, int *size);
 
 int sf_pkread(FILE * f, int foffs, void **out, int *size);
 
-ulong *sf_savearea(int x, int y, int w, int h);
-void sf_restoreareaandfree(ulong * s);
+zlong *sf_savearea(int x, int y, int w, int h);
+void sf_restoreareaandfree(zlong * s);
 #define SF_NOTIMP (-9999)
 
 zword sf_read_key(int timeout, bool cursor, bool allowed, bool text);
@@ -243,7 +240,7 @@ zword sf_read_key(int timeout, bool cursor, bool allowed, bool text);
 int sf_user_fdialog(bool exist, const char *def, const char *filt,
                    const char *title, char **res);
 extern int (*sf_osdialog)(bool ex, const char *def, const char *filt,
-                         const char *tit, char **res, ulong * sbuf, int sbp,
+                         const char *tit, char **res, zlong * sbuf, int sbp,
                          int ew, int eh, int isfull);
 
 void sf_checksound(void);
@@ -255,13 +252,13 @@ void sf_poptextsettings(void);
 
 char *sf_searchfile(char *, int, char *, char *);
 
-void sf_chline(int x, int y, ulong c, int n);
-void sf_cvline(int x, int y, ulong c, int n);
+void sf_chline(int x, int y, zlong c, int n);
+void sf_cvline(int x, int y, zlong c, int n);
 bool sf_flushdisplay(void);
 void sf_getclip(int *x, int *y, int *w, int *h);
-void sf_rect(unsigned long color, int x, int y, int w, int h);
+void sf_rect(zlong color, int x, int y, int w, int h);
 void sf_setclip(int x, int y, int w, int h);
-void sf_wpixel(int x, int y, ulong c);
+void sf_wpixel(int x, int y, zlong c);
 
 void sf_InitProfile(const char *fn);
 void sf_FinishProfile(void);
index 2c7199cd771de14402708c6158f05be39b08ea35..0c2823802965373e1f6873c5d5377c944cb400c1 100644 (file)
@@ -103,7 +103,7 @@ static int bmaxchar(SFONT * s)
 
 static void setglyph(MYFONT * f, FT_Face face, int ch);
 
-static SF_glyph *getglyph(SFONT * s, word c, int allowdef)
+static SF_glyph *getglyph(SFONT * s, zword c, int allowdef)
 {
        if (s) {
                MYFONT *f = (MYFONT *) s;
@@ -121,7 +121,7 @@ static SF_glyph *getglyph(SFONT * s, word c, int allowdef)
 }
 
 
-static int hasglyph(SFONT * fo, word c, int allowdef)
+static int hasglyph(SFONT * fo, zword c, int allowdef)
 {
        return (getglyph(fo, c, allowdef) != NULL);
 }
index b213e0bc0812e1696f3c7ecdf04908427ef461dc..1c7ee8991f3f555f4d9aafd5564efc27c194a095 100644 (file)
 
 #include "../blorb/blorblow.h"
 
-static byte toLinear[256];
-static byte fromLinear[256];
+static zbyte toLinear[256];
+static zbyte fromLinear[256];
 extern bool m_adaptiveMode;
 
-ulong sf_blend(int a, ulong s, ulong d)
+zlong sf_blend(int a, zlong s, zlong d)
 {
-       ulong r;
+       zlong r;
        r = fromLinear[(toLinear[s & 0xff] * a +
                        toLinear[d & 0xff] * (256 - a)) >> 8];
        s >>= 8;
@@ -76,8 +76,8 @@ void sf_setgamma(double gamma)
  */
 
 typedef struct {
-       byte *gfxData;
-       unsigned long offset;
+       zbyte *gfxData;
+       zlong offset;
 } PNGData;
 
 
@@ -89,7 +89,7 @@ static void readPNGData(png_structp png_ptr, png_bytep data, png_size_t length)
 }
 
 
-static int loadpng(byte * data, int length, sf_picture * graphic)
+static int loadpng(zbyte * data, int length, sf_picture * graphic)
 {
        png_bytep *rowPointers = NULL;
        png_structp png_ptr = NULL;
@@ -171,7 +171,7 @@ static int loadpng(byte * data, int length, sf_picture * graphic)
                        graphic->transparentcolor = trans[0];
 
                size = width * height;
-               graphic->pixels = (byte *) malloc(size);
+               graphic->pixels = (zbyte *) malloc(size);
 
                rowPointers = malloc(sizeof(png_bytep) * height);
                for (int i = 0; i < (int)height; i++)
@@ -186,7 +186,7 @@ static int loadpng(byte * data, int length, sf_picture * graphic)
                if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) {
                        graphic->palette_entries = num_palette;
                        for (int i = 0; i < num_palette; i++) {
-                               ulong color =
+                               zlong color =
                                    palette[i].red | (palette[i].
                                                      green << 8) | (palette[i].
                                                                     blue <<
@@ -213,7 +213,7 @@ static int loadpng(byte * data, int length, sf_picture * graphic)
 
                png_set_filler(png_ptr,0xff,PNG_FILLER_AFTER);
                size = width*height*4;
-               graphic->pixels = (byte *) malloc(size);
+               graphic->pixels = (zbyte *) malloc(size);
                rowPointers = malloc(sizeof(png_bytep) * height);
                for (int i = 0; i < (int)height; i++)
                        rowPointers[i] = graphic->pixels + (width * i * 4);
@@ -289,7 +289,7 @@ static void memJPEGTerm(j_decompress_ptr unused)
 }
 
 
-static int loadjpeg(byte * data, int length, sf_picture * graphic)
+static int loadjpeg(zbyte * data, int length, sf_picture * graphic)
 {
        struct jpeg_decompress_struct info;
        struct JPEGErrorInfo error;
@@ -332,7 +332,7 @@ static int loadjpeg(byte * data, int length, sf_picture * graphic)
        graphic->width = width;
        graphic->height = height;
        size = width * height * 4;
-       graphic->pixels = (byte *) malloc(size);
+       graphic->pixels = (zbyte *) malloc(size);
 
        /* Force RGB output */
        info.out_color_space = JCS_RGB;
@@ -343,7 +343,7 @@ static int loadjpeg(byte * data, int length, sf_picture * graphic)
 
        jpeg_start_decompress(&info);
        while ((int)info.output_scanline < height) {
-               byte *pixelRow;
+               zbyte *pixelRow;
                int i;
                jpeg_read_scanlines(&info, buffer, 1);
 
@@ -367,7 +367,7 @@ static int loadjpeg(byte * data, int length, sf_picture * graphic)
  ****************************************************************************
  */
 
-static int loadrect(byte * data, int length, sf_picture * graphic)
+static int loadrect(zbyte * data, int length, sf_picture * graphic)
 {
        graphic->width =
            (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
@@ -389,7 +389,7 @@ static int sf_loadpic(int picture, sf_picture * graphic)
        graphic->adaptive = sf_IsAdaptive(picture) ? TRUE : FALSE;
 
        if (sf_getresource(picture, 1, bb_method_Memory, &res) == bb_err_None) {
-               byte *data = (byte *) res.bbres.data.ptr;
+               zbyte *data = (zbyte *) res.bbres.data.ptr;
                int length = res.bbres.length;
                unsigned int id = res.type;
 
index fe93a376e4eb62050aaecd71b6e340ab653fd98c..c2910a8c053543ff0481b0846edb48dcc35f00f6 100644 (file)
@@ -47,7 +47,7 @@ static char pattern[64];
 static zword pushed = 0;
 static int wentry;
 
-static ulong *sbuffer = NULL;
+static zlong *sbuffer = NULL;
 static int sbpitch;            /* in longs */
 static int ewidth, eheight;
 static int X, Y, W, H, xdlg, ydlg, wdlg, hdlg;
@@ -92,7 +92,7 @@ STATIC void goup()
 typedef struct {
        int x, y, w, h;         /* internal */
         zword(*click) (int, int);
-       ulong back;
+       zlong back;
        int isbutton;
 } BAREA;
 
@@ -118,7 +118,7 @@ static SF_textsetting *ts;
 
 STATIC void frame_upframe(int x, int y, int w, int h)
 {
-       ulong v = O_WHITE;
+       zlong v = O_WHITE;
        sf_chline(x, y, v, w);
        sf_cvline(x, y, v, --h);
        v = O_BLACK;
@@ -137,7 +137,7 @@ STATIC void frame_upframe(int x, int y, int w, int h)
 
 STATIC void frame_downframe(int x, int y, int w, int h)
 {
-       ulong v = O_BLACK;
+       zlong v = O_BLACK;
        sf_chline(x, y, v, w);
        sf_cvline(x, y, v, --h);
        v = O_WHITE;
@@ -219,7 +219,7 @@ STATIC size_t utf8_len(const char *str)
 #endif /* USE_UTF8 */
 
 
-STATIC void writetext(ulong color, const char *s, int x, int y, int w,
+STATIC void writetext(zlong color, const char *s, int x, int y, int w,
                      int center)
 {
        int ox, oy, ow, oh;
@@ -365,11 +365,11 @@ int (*sf_sysdialog)(bool existing, const char *def, const char *filt,
 
 
 STATIC int myosdialog(bool existing, const char *def, const char *filt,
-                     const char *tit, char **res, ulong * sbuf, int sbp,
+                     const char *tit, char **res, zlong * sbuf, int sbp,
                      int ew, int eh, int isfull)
 {
        char *pp;
-       ulong *saved;
+       zlong *saved;
        int y0, y1, y2, x1;
        zword c = 0;
        int wtext, htext, buttw;
@@ -759,7 +759,7 @@ STATIC int utf8_char_pos(char *s, int pos)
 /*********************************************
  * white, black, gray, yellow
  */
-static ulong bcolors[4] = { 0xfcfcfc, 0, 0xa0a0a0, 0xa0d0e0 };
+static zlong bcolors[4] = { 0xfcfcfc, 0, 0xa0a0a0, 0xa0d0e0 };
 
 static unsigned char folderbmp[] = {
        0, 0, 0, 0, 0, 0, 0, 0,
@@ -1001,12 +1001,12 @@ STATIC zword Zselect(int x, int y)
 }
 
 
-extern void sf_videodata(ulong ** sb, int *sp, int *ew, int *eh);
+extern void sf_videodata(zlong ** sb, int *sp, int *ew, int *eh);
 zword sf_yesnooverlay(int xc, int yc, char *t, int saverest)
 {
        zword c = ZC_RETURN;
        int nsav = nbareas;
-       ulong *saved = NULL;
+       zlong *saved = NULL;
        int hx = BUTTW + 3 * SPC, hy = HTEXT + 2 * SPC, heff;
 
        heff = 8 * strlen(t);
index 2b2adbf1bfd5221a2122000a2ac84b66d8519dd5..7dc0b024284c5afd4e03153090dc051b38caa5ac 100644 (file)
@@ -51,10 +51,10 @@ int m_v6scale_x;
 int m_v6scale_y;
 double m_gfxScale_w = 1.0;
 double m_gfxScale_h = 1.0;
-ulong m_defaultFore;
-ulong m_defaultBack;
-ulong m_colours[11];
-ulong m_nonStdColours[NON_STD_COLS];
+zlong m_defaultFore;
+zlong m_defaultBack;
+zlong m_colours[11];
+zlong m_nonStdColours[NON_STD_COLS];
 int m_nonStdIndex;
 bool m_exitPause = 0;
 bool m_lineInput = 0;
@@ -478,7 +478,7 @@ void sf_readsettings(void)
 
 
 /* Get a colour */
-ulong sf_GetColour(int colour)
+zlong sf_GetColour(int colour)
 {
        /* Standard colours */
        if ((colour >= BLACK_COLOUR) && (colour <= DARKGREY_COLOUR))
@@ -500,7 +500,7 @@ ulong sf_GetColour(int colour)
 
 
 /* Get a default colour */
-ulong sf_GetDefaultColour(bool fore)
+zlong sf_GetDefaultColour(bool fore)
 {
        if (m_IsInfocomV6)
                return sf_GetColour(fore ? WHITE_COLOUR : BLACK_COLOUR);
@@ -509,7 +509,7 @@ ulong sf_GetDefaultColour(bool fore)
 
 
 /* Get an index for a non-standard colour */
-int sf_GetColourIndex(ulong colour)
+int sf_GetColourIndex(zlong colour)
 {
        int i, index = -1;
        /* Is this a standard colour? */
@@ -898,7 +898,7 @@ static int loadlocal(int num, int ispic, int method, myresource * res)
 {
        FILE *f;
        int size;
-       byte hd[4];
+       zbyte hd[4];
 
        f = findlocal(ispic, num, &size);
        if (!f)
@@ -950,7 +950,7 @@ static int loadlocal(int num, int ispic, int method, myresource * res)
 int sf_getresource(int num, int ispic, int method, myresource * res)
 {
        int st;
-       ulong usage;
+       zlong usage;
 
        res->bbres.data.ptr = NULL;
        res->file = NULL;
@@ -981,7 +981,7 @@ int sf_getresource(int num, int ispic, int method, myresource * res)
 typedef struct {
        void *next;
        int num, ispic;
-       ulong type;
+       zlong type;
        char *name;
 } LLENTRY;
 
@@ -989,7 +989,7 @@ static LLENTRY *Lpics = NULL, *Lsnds = NULL;
 
 static int numlocal = 0, numlocalpic = 0, numlocalsnd = 0;
 static int p_ispic, p_num;
-static ulong p_type;
+static zlong p_type;
 static char *p_name;
 
 
index d5a45bf87c38dd9e15eaae496f2994f7b0f576af..b04572404808391e54cef8995f3dcb80d833b329 100644 (file)
@@ -52,7 +52,7 @@ typedef struct EFFECT {
        int volume;
        int ended;
        zword eos;
-       ulong endtime;
+       zlong endtime;
 } EFFECT;
 
 /* no effects cache */
@@ -246,7 +246,7 @@ static EFFECT *getaiff(FILE * f, size_t pos, int len, int num)
 static EFFECT *getmodule(FILE * f, size_t pos, int len, int num)
 {
        EFFECT *res;
-       byte h[2];
+       zbyte h[2];
 
        res = new_effect(MOD_TYPE, num);
        if (!res)
index dbdc1105fefa6ccf04f9f81684bdbfe035ff556b..e5d7f547b38474b8063295e0de60f210f08977d6 100644 (file)
@@ -540,17 +540,17 @@ void sf_sleep(int msecs)
 }
 
 #ifdef WIN32
-unsigned long sf_ticks(void)
+zlong sf_ticks(void)
 {
        return (GetTickCount());
 }
 #else
-unsigned long sf_ticks(void)
+zlong sf_ticks(void)
 {
        struct timeval now;
        static struct timeval start;
        static int started = 0;
-       unsigned long ticks;
+       zlong ticks;
        now.tv_sec = now.tv_usec = 0;
        gettimeofday(&now, NULL);
        if (!started) {
@@ -928,7 +928,7 @@ static char *findid(const char *sect, const char *id)
                if (!r)
                        break;
                rq = r + nid;
-               if ((*(byte *) (r - 1) <= ' ')
+               if ((*(zbyte *) (r - 1) <= ' ')
                    && ((*rq == ' ') || (*rq == '='))) {
                        while (*rq)
                                if (*rq++ == '=')
@@ -981,7 +981,7 @@ char *sf_GetProfileString(const char *sect, const char *id, char *def)
                                        p++;
                                        break;
                                }
-                               if ((byte) (*p) > ' ')
+                               if ((zbyte) (*p) > ' ')
                                        break;
                        }
                        if (*p) {
@@ -1032,13 +1032,13 @@ char *sf_GetProfileString(const char *sect, const char *id, char *def)
 #define pshort( b) (((int)((b)[1]) << 8) + (int)((b)[0]))
 
 
-static unsigned myin(void *d, byte ** b)
+static unsigned myin(void *d, zbyte ** b)
 {
        return 0;
 }
 
 
-static int myout(void *udata, byte * b, unsigned n)
+static int myout(void *udata, zbyte * b, unsigned n)
 {
        memmove(udata, b, n);
        udata += n;
@@ -1046,9 +1046,9 @@ static int myout(void *udata, byte * b, unsigned n)
 }
 
 
-static int myunzip(int csize, byte * cdata, byte * udata)
+static int myunzip(int csize, zbyte * cdata, zbyte * udata)
 {
-       byte window[32768];
+       zbyte window[32768];
        z_stream z;
        int st;
 
@@ -1076,8 +1076,8 @@ static int myunzip(int csize, byte * cdata, byte * udata)
 
 int sf_pkread(FILE * f, int foffs, void **out, int *size)
 {
-       byte hd[30];
-       byte *data, *cdata;
+       zbyte hd[30];
+       zbyte *data, *cdata;
        int csize, usize, cmet, skip, st;
 
        fseek(f, foffs, SEEK_SET);
index 1a80fd12158cfa9fb79e8799c5a31528858615eb..ccf5c52c4540e7b9d450b527326474881210e814 100644 (file)
@@ -31,7 +31,7 @@
 
 static char banner[256];
 static int isfullscreen;
-static ulong *sbuffer = NULL;
+static zlong *sbuffer = NULL;
 static int sbpitch;            /* in longs */
 static int dirty = 0;
 static int ewidth, eheight;
@@ -45,7 +45,7 @@ extern bool sdl_active;
 static void sf_quitconf();
 
 static bool ApplyPalette(sf_picture *);
-static ulong screen_palette[16];
+static zlong screen_palette[16];
 
 extern z_header_t z_header;
 
@@ -99,7 +99,7 @@ static void myGrefresh()
 }
 
 
-void sf_wpixel(int x, int y, ulong c)
+void sf_wpixel(int x, int y, zlong c)
 {
        if (x < xmin || x >= xmax || y < ymin || y >= ymax)
                return;
@@ -108,7 +108,7 @@ void sf_wpixel(int x, int y, ulong c)
 }
 
 
-ulong sf_rpixel(int x, int y)
+zlong sf_rpixel(int x, int y)
 {
        if (x < 0 || x >= ewidth || y < 0 || y >= eheight)
                return 0;
@@ -116,7 +116,7 @@ ulong sf_rpixel(int x, int y)
 }
 
 #define MAXCUR 64
-static ulong savedcur[MAXCUR];
+static zlong savedcur[MAXCUR];
 
 static void drawthecursor(int x, int y, int onoff)
 {
@@ -137,7 +137,7 @@ static void drawthecursor(int x, int y, int onoff)
 }
 
 
-bool sf_IsValidChar(unsigned short c)
+bool sf_IsValidChar(zword c)
 {
        if (c >= ZC_ASCII_MIN && c <= ZC_ASCII_MAX)
                return true;
@@ -156,9 +156,9 @@ void sf_drawcursor(bool c)
 }
 
 
-void sf_chline(int x, int y, ulong c, int n)
+void sf_chline(int x, int y, zlong c, int n)
 {
-       ulong *s;
+       zlong *s;
        if (y < ymin || y >= ymax)
                return;
        if (x < xmin) {
@@ -176,9 +176,9 @@ void sf_chline(int x, int y, ulong c, int n)
 }
 
 
-void sf_cvline(int x, int y, ulong c, int n)
+void sf_cvline(int x, int y, zlong c, int n)
 {
-       ulong *s;
+       zlong *s;
        if (x < xmin || x >= xmax)
                return;
        if (y < xmin) {
@@ -198,9 +198,9 @@ void sf_cvline(int x, int y, ulong c, int n)
 }
 
 
-ulong sf_blendlinear(int a, ulong s, ulong d)
+zlong sf_blendlinear(int a, zlong s, zlong d)
 {
-       ulong r;
+       zlong r;
        r = ((s & 0xff) * a + (d & 0xff) * (256 - a)) >> 8;
        s >>= 8;
        d >>= 8;
@@ -220,7 +220,7 @@ void sf_writeglyph(SF_glyph * g)
 
        int w = g->dx;
        int weff = g->xof + g->w;
-       byte *bmp = (byte *) (&(g->bitmap[0]));
+       zbyte *bmp = (zbyte *) (&(g->bitmap[0]));
        int h = g->h;
        int nby = (g->w + 7) / 8;
        int byw = g->w;
@@ -234,7 +234,7 @@ void sf_writeglyph(SF_glyph * g)
        int height = ts->font->height(ts->font);
        int width;
 
-       ulong color, bc;
+       zlong color, bc;
 
        if ((ts->style & REVERSE_STYLE) != 0) {
                bc = ts->fore;
@@ -262,7 +262,7 @@ void sf_writeglyph(SF_glyph * g)
                                int t = *bmp++;
                                if (xx < byw) {
                                        if (t) {
-                                               ulong sval = color;
+                                               zlong sval = color;
                                                if (t < 255)
                                                        sval = sf_blend((int) (t + (t >> 7)), sval, sf_rpixel(x + xx, y));
                                                sf_wpixel(x + xx, y, sval);
@@ -290,9 +290,9 @@ void sf_writeglyph(SF_glyph * g)
 }
 
 
-void sf_fillrect(unsigned long color, int x, int y, int w, int h)
+void sf_fillrect(zlong color, int x, int y, int w, int h)
 {
-       ulong *dst;
+       zlong *dst;
        int i;
        if (x < xmin) {
                w += x - xmin;
@@ -320,7 +320,7 @@ void sf_fillrect(unsigned long color, int x, int y, int w, int h)
 }
 
 
-void sf_rect(unsigned long color, int x, int y, int w, int h)
+void sf_rect(zlong color, int x, int y, int w, int h)
 {
        sf_chline(x, y, color, w);
        sf_chline(x, y + h - 1, color, w);
@@ -380,7 +380,7 @@ int os_peek_colour(void)
 
 static void scroll(int x, int y, int w, int h, int n)
 {
-       ulong *src, *dst;
+       zlong *src, *dst;
        int nmove, step;
        if (n > 0) {
                dst = sbuffer + x + sbpitch * y;
@@ -397,7 +397,7 @@ static void scroll(int x, int y, int w, int h, int n)
                return;
        if (nmove > 0) {
                while (nmove--) {
-                       memmove(dst, src, w * sizeof(ulong));
+                       memmove(dst, src, w * sizeof(zlong));
                        dst += step;
                        src += step;
                }
@@ -414,7 +414,7 @@ bool sf_flushdisplay()
 {
        if (dirty) {
                SDL_UpdateTexture(texture, NULL, sbuffer,
-                                 sbpitch * sizeof(ulong));
+                                 sbpitch * sizeof(zlong));
                myGrefresh();
                dirty = 0;
                return true;
@@ -537,7 +537,7 @@ void sf_initvideo(int W, int H, int full)
                                          SDL_TEXTUREACCESS_STREAMING, W, H)))
                os_fatal("Failed to create texture: %s", SDL_GetError());
 
-       sbuffer = calloc(W * H, sizeof(ulong));
+       sbuffer = calloc(W * H, sizeof(zlong));
        if (!sbuffer)
                os_fatal("Could not create gc");
 
@@ -564,7 +564,7 @@ void os_draw_picture(int picture, int y, int x)
        int ox, oy, ow, oh;
        Zwindow *winpars;
        sf_picture *pic = sf_getpic(picture);
-       ulong *src, *dst, sval, dval, alpha;
+       zlong *src, *dst, sval, dval, alpha;
 
        sf_flushtext();
 
@@ -572,7 +572,7 @@ void os_draw_picture(int picture, int y, int x)
                return;
        if (!pic->pixels)
                return;
-       src = (ulong *) pic->pixels;
+       src = (zlong *) pic->pixels;
 
        x--;
        y--;
@@ -647,8 +647,8 @@ void os_draw_picture(int picture, int y, int x)
                for (yy = 0; yy < eh; yy++) {
                        for (xx = 0; xx < ew; xx++) {
                                dst =
-                                   sbuffer + x + (uint32_t)(xx * m_gfxScale_w) +
-                                   sbpitch * (y + (uint32_t)(yy * m_gfxScale_h));
+                                   sbuffer + x + (zlong)(xx * m_gfxScale_w) +
+                                   sbpitch * (y + (zlong)(yy * m_gfxScale_h));
                                sval = src[xx];
                                alpha = (sval >> 24);
                                if (alpha == 255)
@@ -673,7 +673,7 @@ void os_draw_picture(int picture, int y, int x)
 }
 
 
-static ulong mytimeout;
+static zlong mytimeout;
 int mouse_button;
 static int numAltQ = 0;
 
@@ -1180,7 +1180,7 @@ void sf_DrawInput(zchar * buffer, int pos, int ptx, int pty, int width,
  */
 zword os_read_mouse(void)
 {
-       byte c;
+       zbyte c;
        int x, y;
        zword btn = 0;
        /* Get the mouse position */
@@ -1238,9 +1238,9 @@ void os_more_prompt(void)
 }
 
 
-ulong *sf_savearea(int x, int y, int w, int h)
+zlong *sf_savearea(int x, int y, int w, int h)
 {
-       ulong *r, *p, *s;
+       zlong *r, *p, *s;
        int i;
 
        if (x < 0) {
@@ -1261,7 +1261,7 @@ ulong *sf_savearea(int x, int y, int w, int h)
        if (h <= 0)
                return NULL;
 
-       r = p = malloc((w * h + 4) * sizeof(ulong));
+       r = p = malloc((w * h + 4) * sizeof(zlong));
        if (!r)
                return NULL;
 
@@ -1272,7 +1272,7 @@ ulong *sf_savearea(int x, int y, int w, int h)
 
        s = sbuffer + x + y * sbpitch;
        for (i = 0; i < h; i++) {
-               memmove(p, s, w * sizeof(ulong));
+               memmove(p, s, w * sizeof(zlong));
                p += w;
                s += sbpitch;
        }
@@ -1280,9 +1280,9 @@ ulong *sf_savearea(int x, int y, int w, int h)
 }
 
 
-void sf_restoreareaandfree(ulong * s)
+void sf_restoreareaandfree(zlong * s)
 {
-       ulong *p, *d;
+       zlong *p, *d;
        int i, x, y, w, h;
        if (!s)
                return;
@@ -1295,7 +1295,7 @@ void sf_restoreareaandfree(ulong * s)
 
        d = sbuffer + x + y * sbpitch;
        for (i = 0; i < h; i++) {
-               memmove(d, p, w * sizeof(ulong));
+               memmove(d, p, w * sizeof(zlong));
                p += w;
                d += sbpitch;
        }
@@ -1307,7 +1307,7 @@ void sf_restoreareaandfree(ulong * s)
 
 
 int (*sf_osdialog)(bool ex, const char *def, const char *filt, const char *tit,
-                  char **res, ulong * sbuf, int sbp, int ew, int eh,
+                  char **res, zlong * sbuf, int sbp, int ew, int eh,
                   int isfull) = NULL;
 
 
@@ -1322,7 +1322,7 @@ int sf_user_fdialog(bool existing, const char *defaultname, const char *filter,
 }
 
 
-void sf_videodata(ulong ** sb, int *sp, int *ew, int *eh)
+void sf_videodata(zlong ** sb, int *sp, int *ew, int *eh)
 {
        *sb = sbuffer;
        *sp = sbpitch;
@@ -1367,7 +1367,7 @@ static bool ApplyPalette(sf_picture * graphic)
        bool changed = FALSE;
        int i, colors;
 
-       memset(&screen_palette, 0, sizeof(ulong));
+       memset(&screen_palette, 0, sizeof(zlong));
 
        if (graphic->usespalette) {
                colors = graphic->palette_entries;