| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifndef _SF_FROTZ_H |
| 9 |
#define _SF_FROTZ_H |
| 10 |
|
| 11 |
#include "sf_defines.h" |
| 12 |
#include "../common/frotz.h" |
| 13 |
#include "../blorb/blorb.h" |
| 14 |
|
| 15 |
#include <stdint.h> |
| 16 |
|
| 17 |
typedef struct { |
| 18 |
bb_result_t bbres; |
| 19 |
zlong type; |
| 20 |
FILE *file; |
| 21 |
} myresource; |
| 22 |
|
| 23 |
int sf_getresource(int num, int ispic, int method, myresource * res); |
| 24 |
void sf_freeresource(myresource * res); |
| •25 |
int sf_IsAdaptive(int picture); |
| 26 |
|
| 27 |
#ifndef true |
| 28 |
#define true 1 |
| 29 |
#endif |
| 30 |
#ifndef false |
| 31 |
#define false 0 |
| 32 |
#endif |
| 33 |
|
| 34 |
#define NON_STD_COLS 238 |
| 35 |
|
| 36 |
|
| 37 |
#define PATH1 "ZCODE_PATH" |
| 38 |
#define PATH2 "INFOCOM_PATH" |
| 39 |
|
| 40 |
#define CONFIG_FILE ".sfrotzrc" |
| 41 |
|
| 42 |
#define DEFAULT_WIDTH 640 |
| 43 |
#define DEFAULT_HEIGHT 400 |
| 44 |
|
| 45 |
#define MAX(x,y) ((x)>(y)) ? (x) : (y) |
| 46 |
#define MIN(x,y) ((x)<(y)) ? (x) : (y |
| 47 |
|
| 48 |
#ifdef WIN32 |
| 49 |
#define HOMEDIR "USERPROFILE" |
| 50 |
#else |
| 51 |
#define HOMEDIR "HOME" |
| 52 |
#endif |
| 53 |
|
| 54 |
|
| 55 |
static inline zlong RGB5ToTrue(zword w) |
| 56 |
{ |
| 57 |
int _r = w & 0x001F; |
| 58 |
int _g = (w & 0x03E0) >> 5; |
| 59 |
int _b = (w & 0x7C00) >> 10; |
| 60 |
_r = (_r << 3) | (_r >> 2); |
| 61 |
_g = (_g << 3) | (_g >> 2); |
| 62 |
_b = (_b << 3) | (_b >> 2); |
| 63 |
return (zlong) (_r | (_g << 8) | (_b << 16)); |
| 64 |
} |
| 65 |
|
| 66 |
static inline zword TrueToRGB5(zlong u) |
| 67 |
{ |
| 68 |
return (zword) (((u >> 3) & 0x001f) | ((u >> 6) & 0x03e0) | |
| 69 |
((u >> 9) & 0x7c00)); |
| 70 |
} |
| 71 |
|
| 72 |
void reset_memory(void); |
| 73 |
void replay_close(void); |
| 74 |
void set_header_extension(int entry, zword val); |
| 75 |
int colour_in_use(zword colour); |
| 76 |
|
| 77 |
|
| •78 |
extern int m_tandy; |
| 79 |
extern int m_v6scale; |
| 80 |
extern double m_gfxScale_w; |
| 81 |
extern double m_gfxScale_h; |
| 82 |
extern zlong m_defaultFore; |
| 83 |
extern zlong m_defaultBack; |
| 84 |
extern zlong m_colours[11]; |
| 85 |
extern zlong m_nonStdColours[NON_STD_COLS]; |
| 86 |
extern int m_nonStdIndex; |
| •87 |
extern int m_lineInput; |
| 88 |
extern int m_morePrompts; |
| 89 |
extern int AcWidth; |
| 90 |
extern int AcHeight; |
| 91 |
extern int m_random_seed; |
| 92 |
extern int m_fullscreen; |
| 93 |
extern char *m_fontfiles[9]; |
| •94 |
extern int m_localfiles; |
| 95 |
extern int m_no_sound; |
| 96 |
extern int m_vga_fonts; |
| 97 |
extern int SFdticks; |
| 98 |
extern char *m_fontdir; |
| •99 |
extern int m_aafonts; |
| 100 |
extern char *m_setupfile; |
| 101 |
extern int m_frequency; |
| 102 |
|
| 103 |
extern double m_gamma; |
| 104 |
extern double m_xscale; |
| 105 |
extern double m_yscale; |
| 106 |
|
| •107 |
extern int sdl_active; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
int sf_load_resources(void); |
| 113 |
|
| 114 |
typedef struct { |
| 115 |
int number; |
| 116 |
int width, height; |
| 117 |
zbyte *pixels; |
| 118 |
zlong palette[16]; |
| 119 |
int palette_entries; |
| 120 |
int transparentcolor; |
| •121 |
int adaptive; |
| 122 |
int usespalette; |
| 123 |
} sf_picture; |
| 124 |
|
| 125 |
#define DEFAULT_GAMMA 2.2 |
| 126 |
|
| 127 |
void sf_setgamma(double gamma); |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
sf_picture *sf_getpic(int num); |
| 132 |
|
| 133 |
void sf_flushtext(void); |
| 134 |
|
| 135 |
|
| 136 |
typedef struct { |
| 137 |
zbyte dx; |
| 138 |
zbyte w, h; |
| 139 |
char xof, yof; |
| 140 |
zbyte bitmap[0]; |
| 141 |
} SF_glyph; |
| 142 |
|
| 143 |
typedef struct sfontstruct SFONT; |
| 144 |
|
| 145 |
extern SFONT *(*ttfontloader)(char *fspec, SFONT * like, int *err); |
| 146 |
extern void (*ttfontsdone)(); |
| 147 |
|
| 148 |
struct sfontstruct { |
| 149 |
int refcount; |
| 150 |
void (*destroy)(SFONT *); |
| 151 |
int (*height)(SFONT *); |
| 152 |
int (*ascent)(SFONT *); |
| 153 |
int (*descent)(SFONT *); |
| 154 |
int (*minchar)(SFONT *); |
| 155 |
int (*maxchar)(SFONT *); |
| 156 |
int (*hasglyph)(SFONT *, zword, int); |
| 157 |
SF_glyph *(*getglyph)(SFONT *, zword, int); |
| 158 |
int antialiased; |
| 159 |
void *data; |
| 160 |
}; |
| 161 |
|
| 162 |
typedef struct { |
| 163 |
SFONT *font; |
| 164 |
int proportional; |
| 165 |
int style, zfontnum; |
| 166 |
int cx, cy; |
| 167 |
int oh; |
| 168 |
zlong fore, back; |
| •169 |
int foreDefault, backDefault, backTransparent; |
| 170 |
} SF_textsetting; |
| 171 |
|
| 172 |
SF_textsetting *sf_curtextsetting(void); |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
int sf_charwidth(zword c, int *oh); |
| 179 |
|
| 180 |
void sf_writeglyph(SF_glyph * g); |
| 181 |
|
| 182 |
void sf_fillrect(zlong color, int x, int y, int w, int h); |
| 183 |
|
| 184 |
int sf_GetProfileInt(const char *sect, const char *id, int def); |
| 185 |
double sf_GetProfileDouble(const char *sect, const char *id, double def); |
| 186 |
char *sf_GetProfileString(const char *sect, const char *id, char *def); |
| 187 |
|
| 188 |
void sf_readsettings(void); |
| 189 |
|
| 190 |
zlong sf_GetColour(int colour); |
| •191 |
zlong sf_GetDefaultColour(int fore); |
| 192 |
int sf_GetColourIndex(zlong colour); |
| 193 |
|
| 194 |
void sf_initvideo(int w, int h, int full); |
| 195 |
|
| 196 |
int sf_initsound(void); |
| 197 |
|
| 198 |
void sf_initfonts(void); |
| 199 |
|
| 200 |
void sf_setdialog(void); |
| 201 |
void sf_initloader(void); |
| 202 |
|
| 203 |
void sf_cleanup_all(void); |
| 204 |
void sf_regcleanfunc(void *f, const char *nam); |
| 205 |
#define CLEANREG( f) sf_regcleanfunc( (void *)f, #f) |
| 206 |
|
| 207 |
const char *sf_msgstring(int id); |
| 208 |
|
| 209 |
|
| 210 |
enum { IDS_BLORB_GLULX, IDS_BLORB_NOEXEC, IDS_MORE, IDS_HIT_KEY_EXIT, IDS_TITLE, |
| 211 |
IDS_FATAL, IDS_FROTZ, IDS_FAIL_DIRECTSOUND, IDS_FAIL_MODPLUG, |
| 212 |
IDS_ABOUT_INFO, |
| 213 |
IDS_SAVE_FILTER, IDS_SAVE_TITLE, IDS_RESTORE_TITLE, |
| 214 |
IDS_SCRIPT_FILTER, IDS_SCRIPT_TITLE, |
| 215 |
IDS_RECORD_FILTER, IDS_RECORD_TITLE, IDS_PLAYBACK_TITLE, |
| 216 |
IDS_AUX_FILTER, IDS_SAVE_AUX_TITLE, IDS_LOAD_AUX_TITLE |
| 217 |
}; |
| 218 |
|
| •219 |
int sf_IsInfocomV6(void); |
| 220 |
|
| 221 |
zlong sf_blend(int a, zlong s, zlong d); |
| 222 |
|
| 223 |
void sf_sleep(int millisecs); |
| 224 |
|
| 225 |
zlong sf_ticks(void); |
| 226 |
|
| 227 |
void sf_DrawInput(zchar * buffer, int pos, int ptx, int pty, int width, |
| •228 |
int cursor); |
| 229 |
|
| 230 |
int sf_aiffwav(FILE * f, int foffs, void **wav, int *size); |
| 231 |
|
| 232 |
int sf_pkread(FILE * f, int foffs, void **out, int *size); |
| 233 |
|
| 234 |
zlong *sf_savearea(int x, int y, int w, int h); |
| 235 |
void sf_restoreareaandfree(zlong * s); |
| 236 |
#define SF_NOTIMP (-9999) |
| 237 |
|
| •238 |
zword sf_read_key(int timeout, int cursor, int allowed, int text); |
| 239 |
|
| •240 |
int sf_user_fdialog(int exist, const char *def, const char *filt, |
| 241 |
const char *title, char **res); |
| •242 |
extern int (*sf_osdialog)(int ex, const char *def, const char *filt, |
| 243 |
const char *tit, char **res, zlong * sbuf, int sbp, |
| 244 |
int ew, int eh, int isfull); |
| 245 |
|
| 246 |
void sf_checksound(void); |
| 247 |
|
| 248 |
void sf_installhandlers(void); |
| 249 |
|
| 250 |
void sf_pushtextsettings(void); |
| 251 |
void sf_poptextsettings(void); |
| 252 |
|
| 253 |
char *sf_searchfile(char *, int, char *, char *); |
| 254 |
|
| 255 |
void sf_chline(int x, int y, zlong c, int n); |
| 256 |
void sf_cvline(int x, int y, zlong c, int n); |
| •257 |
int sf_flushdisplay(void); |
| 258 |
void sf_getclip(int *x, int *y, int *w, int *h); |
| 259 |
void sf_rect(zlong color, int x, int y, int w, int h); |
| 260 |
void sf_setclip(int x, int y, int w, int h); |
| 261 |
void sf_wpixel(int x, int y, zlong c); |
| 262 |
|
| 263 |
void sf_InitProfile(const char *fn); |
| 264 |
void sf_FinishProfile(void); |
| 265 |
|
| 266 |
#ifdef WIN32 |
| 267 |
#define OS_PATHSEP ';' |
| 268 |
#define OS_DIRSEP '\\' |
| 269 |
#else |
| 270 |
#define OS_PATHSEP ':' |
| 271 |
#define OS_DIRSEP '/' |
| 272 |
#endif |
| 273 |
|
| 274 |
#define DEFSIZE 14 |
| 275 |
|
| 276 |
|
| 277 |
#define VK_TAB 0x16 |
| 278 |
#define VK_INS 0x17 |
| 279 |
#define VK_PAGE_UP 0x18 |
| 280 |
#define VK_PAGE_DOWN 0x19 |
| 281 |
#define VK_DEL 0x100 |
| 282 |
|
| 283 |
|
| 284 |
typedef struct CONVstruct CONV; |
| 285 |
struct CONVstruct { |
| 286 |
double ratio; |
| 287 |
|
| 288 |
int channels; |
| 289 |
int bytespersam; |
| 290 |
|
| 291 |
int (*doCONV)(CONV *, FILE *, void *, int, int); |
| 292 |
void (*finishCONV)(CONV *); |
| 293 |
int maxin, maxout; |
| 294 |
float *inbuf, *outbuf; |
| 295 |
void *aux; |
| 296 |
}; |
| 297 |
|
| 298 |
#endif |