15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "pcfont.h"
#include "quarks.h"
#include "heromesh.h"
#define fatal(...) do{ fprintf(stderr,__VA_ARGS__); exit(1); }while(0)
SDL_Surface*screen;
Uint16 picture_size;
static SDL_Surface*picts;
static Uint8*curpic;
static const char default_palette[]=
|
<
<
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "pcfont.h"
#include "quarks.h"
#include "heromesh.h"
SDL_Surface*screen;
Uint16 picture_size;
static SDL_Surface*picts;
static Uint8*curpic;
static const char default_palette[]=
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
int xx,yy;
const unsigned char*f;
if(x+8*len>screen->w) len=(screen->w-x)>>3;
if(len<=0 || y+8>screen->h) return;
pix+=y*pitch+x;
while(*t) {
f=fontdata+(*t<<3);
for(yy=0;yy<8;yy++) {
for(xx=0;xx<8;xx++) p[xx]=(*f<<xx)&128?fg:bg;
p+=pitch;
++f;
}
t++;
if(!--len) return;
}
}
static Uint16 decide_picture_size(int nwantsize,const Uint8*wantsize,const Uint16*havesize) {
int i,j;
if(!nwantsize) fatal("Unable to determine what picture size is wanted\n");
for(i=0;i<nwantsize;i++) if(havesize[j=wantsize[i]]) return j;
|
>
>
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
int xx,yy;
const unsigned char*f;
if(x+8*len>screen->w) len=(screen->w-x)>>3;
if(len<=0 || y+8>screen->h) return;
pix+=y*pitch+x;
while(*t) {
f=fontdata+(*t<<3);
p=pix;
for(yy=0;yy<8;yy++) {
for(xx=0;xx<8;xx++) p[xx]=(*f<<xx)&128?fg:bg;
p+=pitch;
++f;
}
t++;
if(!--len) return;
pix+=8;
}
}
static Uint16 decide_picture_size(int nwantsize,const Uint8*wantsize,const Uint16*havesize) {
int i,j;
if(!nwantsize) fatal("Unable to determine what picture size is wanted\n");
for(i=0;i<nwantsize;i++) if(havesize[j=wantsize[i]]) return j;
|
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
}
nam[i]=0;
if(i>4 && !memcmp(".IMG",nam+i-4,4)) {
j=1;
if(n++==32768) fatal("Too many pictures\n");
sqlite3_reset(st);
sqlite3_bind_int(st,1,n);
sqlite3_bind_text(st,2,nam,i,SQLITE_TRANSIENT);
sqlite3_bind_int64(st,3,ftell(fp)+4);
while((i=sqlite3_step(st))==SQLITE_ROW);
if(i!=SQLITE_DONE) fatal("SQL error (%d): %s\n",i,sqlite3_errmsg(userdb));
} else {
j=0;
}
i=fgetc(fp)<<16;
|
|
|
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
}
nam[i]=0;
if(i>4 && !memcmp(".IMG",nam+i-4,4)) {
j=1;
if(n++==32768) fatal("Too many pictures\n");
sqlite3_reset(st);
sqlite3_bind_int(st,1,n);
sqlite3_bind_text(st,2,nam,i-4,SQLITE_TRANSIENT);
sqlite3_bind_int64(st,3,ftell(fp)+4);
while((i=sqlite3_step(st))==SQLITE_ROW);
if(i!=SQLITE_DONE) fatal("SQL error (%d): %s\n",i,sqlite3_errmsg(userdb));
} else {
j=0;
}
i=fgetc(fp)<<16;
|
319
320
321
322
323
324
325
326
|
case 'p': i|=SDL_HWPALETTE; break;
case 'r': i|=SDL_RESIZABLE; break;
case 'y': i|=SDL_ASYNCBLIT; break;
}
if(!(i&SDL_HWSURFACE)) i|=SDL_SWSURFACE;
screen=SDL_SetVideoMode(w,h,8,i);
if(!screen) fatal("Failed to initialize screen mode: %s\n",SDL_GetError());
}
|
>
>
>
>
>
>
>
|
>
|
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
case 'p': i|=SDL_HWPALETTE; break;
case 'r': i|=SDL_RESIZABLE; break;
case 'y': i|=SDL_ASYNCBLIT; break;
}
if(!(i&SDL_HWSURFACE)) i|=SDL_SWSURFACE;
screen=SDL_SetVideoMode(w,h,8,i);
if(!screen) fatal("Failed to initialize screen mode: %s\n",SDL_GetError());
optionquery[1]=Q_keyRepeat;
if(v=xrm_get_resource(resourcedb,optionquery,optionquery,2)) {
w=strtol(v,(void*)&v,10);
h=strtol(v,0,10);
SDL_EnableKeyRepeat(w,h);
} else {
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
}
}
|