|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T i
Length: 16377 (0x3ff9)
Types: TextFile
Names: »icon.c.orig«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/X/Xwanderer/icon.c.orig«
#include "wand_head.h"
/* declare all of the pixmaps */
#ifdef XWANDER
void paint_small_square();
extern playerfacing;
extern tinymode;
/* first the 'large' pixmaps (64x64) */
Pixmap space_pm, wall_pm, larrow_pm, rarrow_pm, rock_pm, dirt_pm, fwdslide_pm,
backslide_pm, diamond_pm, brick_pm, playerl_pm, playerr_pm, wayout_pm,
landmine_pm, monster_pm, sprite_pm, timecapsule_pm, cage_pm, teleport_pm,
whoops_pm;
/* the 'tiny' pixmaps (16x16) */
Pixmap space_tpm, wall_tpm, larrow_tpm, rarrow_tpm, rock_tpm, dirt_tpm,
fwdslide_tpm, backslide_tpm, diamond_tpm, brick_tpm, player_tpm, wayout_tpm,
landmine_tpm, monster_tpm, sprite_tpm, timecapsule_tpm, cage_tpm, teleport_tpm,
whoops_tpm;
int scorefonthigh, scorefonta, msgfonthigh, msgfonta, tablefonthigh, tablefonta;
int tablefontwide;
XFontStruct *scorefont, *msgfont, *tablefont;
GC scorefontgc, msgfontgc, linegc, tablegc;
#endif
int do_repaint = 1;
#ifndef XWANDER
void draw_symbol(x,y,ch)
int x,y;
char ch;
{
char icon[2][4],
(*iconrow)[4] = icon;
switch(ch)
{
case ' ':
strcpy((*iconrow++)," ");
strcpy((*iconrow)," ");
break;
case '#':
strcpy(*iconrow++,"###");
strcpy(*iconrow,"###");
break;
case '<':
strcpy(*iconrow++,"<--");
strcpy(*iconrow,"<--");
break;
case '>':
strcpy(*iconrow++,"-->");
strcpy(*iconrow,"-->");
break;
case 'O':
strcpy(*iconrow++,"/^\\");
strcpy(*iconrow,"\\_/");
break;
case ':':
strcpy(*iconrow++,". .");
strcpy(*iconrow," . ");
break;
case '/':
strcpy(*iconrow++," _/");
strcpy(*iconrow,"/ ");
break;
case '\\':
strcpy(*iconrow++,"\\_ ");
strcpy(*iconrow," \\");
break;
case '*':
strcpy(*iconrow++,"/$\\");
strcpy(*iconrow, "\\$/");
break;
case '=':
strcpy(*iconrow++,"=-=");
strcpy(*iconrow, "-=-");
break;
case '@':
strcpy(*iconrow++," o ");
strcpy(*iconrow, "<|>");
break;
case 'T':
strcpy(*iconrow++,"(*)");
strcpy(*iconrow, "(*)");
break;
case 'X':
strcpy(*iconrow++,"Way");
strcpy(*iconrow, "Out");
break;
case '!':
strcpy(*iconrow++," I ");
strcpy(*iconrow, " o ");
break;
case 'M':
strcpy(*iconrow++,"}o{");
strcpy(*iconrow, "/^\\");
break;
case 'S':
strcpy(*iconrow++,"-o-");
strcpy(*iconrow, "/*\\");
break;
case 'C':
strcpy(*iconrow++," ");
strcpy(*iconrow, "<O>");
break;
case '+':
strcpy(*iconrow++,"TTT");
strcpy(*iconrow, "III");
break;
default:
strcpy(*iconrow++,"OOO");
strcpy(*iconrow, "OOO");
break;
};
move(y+1,x+1);
iconrow--;
addstr(*iconrow++);
move(y+2,x+1);
addstr(*iconrow);
}
#else
Pixmap tiny_symbol_pixmap(), symbol_pixmap();
GC symbol_gc();
void draw_symbol(x,y,ch)
int x,y;
char ch;
{
Pixmap p = symbol_pixmap(ch);
GC g = symbol_gc(ch);
static int drawn[ROWLEN+1][NOOFROWS+1];
if (tinymode) { paint_small_square(x,y,ch); return; }
if (do_repaint) {
int i, j;
for (i = 0; i < ROWLEN; i++)
for (j = 0; j < NOOFROWS+1; j++)
drawn[i][j] = -1;
do_repaint = 0;
}
/* only paint area if we have to */
if (drawn[x][y] != ch) {
XCopyArea(dpy, p, win, g, 0, 0, ICON_WIDE, ICON_HIGH,
x * ICON_WIDE + 5, y * ICON_HIGH + 5);
drawn[x][y] = ch;
}
}
Pixmap symbol_pixmap(ch)
int ch;
{
Pixmap picture;
switch(ch) {
case ' ':
picture = space_pm;
break;
case '#':
picture = wall_pm;
break;
case '<':
picture = larrow_pm;
break;
case '>':
picture = rarrow_pm;
break;
case 'O':
picture = rock_pm;
break;
case ':':
picture = dirt_pm;
break;
case '/':
picture = fwdslide_pm;
break;
case '\\':
picture = backslide_pm;
break;
case '*':
picture = diamond_pm;
break;
case '=':
picture = brick_pm;
break;
case '@':
if (playerfacing == 1)
picture = playerl_pm;
else
picture = playerr_pm;
break;
case 'T':
picture = teleport_pm;
break;
case 'X':
picture = wayout_pm;
break;
case '!':
picture = landmine_pm;
break;
case 'M':
picture = monster_pm;
break;
case 'S':
picture = sprite_pm;
break;
case 'C':
picture = timecapsule_pm;
break;
case '+':
picture = cage_pm;
break;
default:
picture = brick_pm;
break;
}
return(picture);
}
void paint_small_square(x,y,ch)
int x,y;
char ch;
{
Pixmap p = tiny_symbol_pixmap(ch);
GC g = symbol_gc(ch);
x++;
y++;
if (ch == ' ' && !tinymode) return;
XCopyArea(dpy, p, win, g, 0, 0, SMALL_WIDE, SMALL_HIGH,
x * SMALL_WIDE + 13, y * SMALL_HIGH + 83);
}
Pixmap tiny_symbol_pixmap(ch)
int ch;
{
Pixmap picture;
switch(ch) {
case ' ':
picture = space_tpm;
break;
case '#':
picture = wall_tpm;
break;
case '<':
picture = larrow_tpm;
break;
case '>':
picture = rarrow_tpm;
break;
case 'O':
picture = rock_tpm;
break;
case ':':
picture = dirt_tpm;
break;
case '/':
picture = fwdslide_tpm;
break;
case '\\':
picture = backslide_tpm;
break;
case '*':
picture = diamond_tpm;
break;
case '=':
picture = brick_tpm;
break;
case '@':
picture = player_tpm;
break;
case 'T':
picture = teleport_tpm;
break;
case 'X':
picture = wayout_tpm;
break;
case '!':
picture = landmine_tpm;
break;
case 'M':
picture = monster_tpm;
break;
case 'S':
picture = sprite_tpm;
break;
case 'C':
picture = timecapsule_tpm;
break;
case '+':
picture = cage_tpm;
break;
default:
picture = brick_pm;
break;
}
return(picture);
}
GC symbol_gc(ch)
int ch;
{
/* this should return an appropriate GC when color is added */
return(globgc);
}
Pixmap MakePixmap(dpy, root, data ,width, height)
Display *dpy;
Drawable root;
short *data;
unsigned int width, height;
{
XImage ximage;
GC pgc;
XGCValues gcv;
Pixmap pid;
pid = XCreatePixmap(dpy,root,width,height,
DefaultDepth(dpy,DefaultScreen(dpy)));
gcv.foreground = BlackPixel(dpy,DefaultScreen(dpy));
gcv.background = WhitePixel(dpy,DefaultScreen(dpy));
pgc = XCreateGC(dpy, pid, GCForeground | GCBackground, &gcv);
ximage.height = height;
ximage.width = width;
ximage.xoffset = 0;
ximage.format = XYBitmap;
ximage.data = (char *) data;
ximage.byte_order = LSBFirst;
ximage.bitmap_unit = 16;
ximage.bitmap_bit_order = LSBFirst;
ximage.bitmap_pad = 16;
ximage.bytes_per_line = (width + 15) / 16 * 2;
ximage.depth = 1;
XPutImage(dpy,pid,pgc,&ximage,0,0,0,0,width,height);
XFreeGC(dpy,pgc);
return(pid);
}
/* the big pixmaps */
#include "icons/space_bm"
#include "icons/wall_bm"
#include "icons/larrow_bm"
#include "icons/rarrow_bm"
#include "icons/rock_bm"
#include "icons/dirt_bm"
#include "icons/fwdslide_bm"
#include "icons/backslide_bm"
#include "icons/diamond_bm"
#include "icons/brick_bm"
#include "icons/playerr_bm"
#include "icons/playerl_bm"
#include "icons/wayout_bm"
#include "icons/landmine_bm"
#include "icons/monster_bm"
#include "icons/sprite_bm"
#include "icons/timecapsule_bm"
#include "icons/cage_bm"
#include "icons/teleport_bm"
#include "icons/whoops_bm"
/* the tiny pixmaps */
#include "icons/space_tbm"
#include "icons/wall_tbm"
#include "icons/larrow_tbm"
#include "icons/rarrow_tbm"
#include "icons/rock_tbm"
#include "icons/dirt_tbm"
#include "icons/fwdslide_tbm"
#include "icons/backslide_tbm"
#include "icons/diamond_tbm"
#include "icons/brick_tbm"
#include "icons/player_tbm"
#include "icons/wayout_tbm"
#include "icons/landmine_tbm"
#include "icons/monster_tbm"
#include "icons/sprite_tbm"
#include "icons/timecapsule_tbm"
#include "icons/cage_tbm"
#include "icons/teleport_tbm"
#include "icons/whoops_tbm"
build_pixmaps()
{
char *cp;
space_pm = MakePixmap(dpy, win, space_bm_bits, 64, 64);
wall_pm = MakePixmap(dpy, win, wall_bm_bits, 64, 64);
larrow_pm = MakePixmap(dpy, win, larrow_bm_bits, 64, 64);
rarrow_pm = MakePixmap(dpy, win, rarrow_bm_bits, 64, 64);
rock_pm = MakePixmap(dpy, win, rock_bm_bits, 64, 64);
dirt_pm = MakePixmap(dpy, win, dirt_bm_bits, 64, 64);
fwdslide_pm = MakePixmap(dpy, win, fwdslide_bm_bits, 64, 64);
backslide_pm = MakePixmap(dpy, win, backslide_bm_bits, 64, 64);
diamond_pm = MakePixmap(dpy, win, diamond_bm_bits, 64, 64);
brick_pm = MakePixmap(dpy, win, brick_bm_bits, 64, 64);
playerl_pm = MakePixmap(dpy, win, playerl_bm_bits, 64, 64);
playerr_pm = MakePixmap(dpy, win, playerr_bm_bits, 64, 64);
wayout_pm = MakePixmap(dpy, win, wayout_bm_bits, 64, 64);
landmine_pm = MakePixmap(dpy, win, landmine_bm_bits, 64, 64);
monster_pm = MakePixmap(dpy, win, monster_bm_bits, 64, 64);
sprite_pm = MakePixmap(dpy, win, sprite_bm_bits, 64, 64);
timecapsule_pm = MakePixmap(dpy, win, timecapsule_bm_bits, 64, 64);
cage_pm = MakePixmap(dpy, win, cage_bm_bits, 64, 64);
teleport_pm = MakePixmap(dpy, win, teleport_bm_bits, 64, 64);
whoops_pm = MakePixmap(dpy, win, whoops_bm_bits, 64, 64);
space_tpm = MakePixmap(dpy, win, space_tbm_bits, 16, 16);
wall_tpm = MakePixmap(dpy, win, wall_tbm_bits, 16, 16);
larrow_tpm = MakePixmap(dpy, win, larrow_tbm_bits, 16, 16);
rarrow_tpm = MakePixmap(dpy, win, rarrow_tbm_bits, 16, 16);
rock_tpm = MakePixmap(dpy, win, rock_tbm_bits, 16, 16);
dirt_tpm = MakePixmap(dpy, win, dirt_tbm_bits, 16, 16);
fwdslide_tpm = MakePixmap(dpy, win, fwdslide_tbm_bits, 16, 16);
backslide_tpm = MakePixmap(dpy, win, backslide_tbm_bits, 16, 16);
diamond_tpm = MakePixmap(dpy, win, diamond_tbm_bits, 16, 16);
brick_tpm = MakePixmap(dpy, win, brick_tbm_bits, 16, 16);
player_tpm = MakePixmap(dpy, win, player_tbm_bits, 16, 16);
wayout_tpm = MakePixmap(dpy, win, wayout_tbm_bits, 16, 16);
landmine_tpm = MakePixmap(dpy, win, landmine_tbm_bits, 16, 16);
monster_tpm = MakePixmap(dpy, win, monster_tbm_bits, 16, 16);
sprite_tpm = MakePixmap(dpy, win, sprite_tbm_bits, 16, 16);
timecapsule_tpm = MakePixmap(dpy, win, timecapsule_tbm_bits, 16, 16);
cage_tpm = MakePixmap(dpy, win, cage_tbm_bits, 16, 16);
teleport_tpm = MakePixmap(dpy, win, teleport_tbm_bits, 16, 16);
whoops_tpm = MakePixmap(dpy, win, whoops_tbm_bits, 16, 16);
/* build all of the GC's here too! */
globgc = XCreateGC(dpy, win, 0, 0);
XSetFunction(dpy, globgc, GXcopyInverted);
/* create the message font gc and load the message font */
msgfontgc = XCreateGC(dpy, win, 0, 0);
XSetFunction(dpy, msgfontgc, GXcopyInverted);
linegc = XCreateGC(dpy, win, 0, 0);
XSetFunction(dpy, linegc, GXcopy);
XSetLineAttributes(dpy,linegc, 2, LineSolid, CapButt, JoinMiter);
cp = (char *)getenv("MSGFONT");
if (!cp) cp = "vr-20";
msgfont = XLoadQueryFont(dpy, cp);
if (msgfont == 0) {
fprintf(stderr,"Can't load (msgfont) %s. Bye!\n",cp);
exit(1);
}
msgfonthigh = msgfont->max_bounds.ascent+msgfont->max_bounds.descent;
msgfonta = msgfont->max_bounds.ascent;
XSetFont(dpy, msgfontgc, msgfont->fid);
/* create the highscore table gc and load the font */
tablegc = XCreateGC(dpy, win, 0, 0);
cp =(char *) getenv("TABLEFONT");
if (!cp) cp = "8x13bold";
tablefont = XLoadQueryFont(dpy, cp);
if (tablefont == 0) {
fprintf(stderr,"Can't load (tablefont) %s. Bye!\n",cp);
exit(1);
}
tablefonthigh = tablefont->max_bounds.ascent+tablefont->max_bounds.descent;
tablefontwide = tablefont->max_bounds.width;
tablefonta = tablefont->max_bounds.ascent;
XSetFont(dpy, tablegc, tablefont->fid);
/* create the score font gc and load the score font */
scorefontgc = XCreateGC(dpy, win, 0, 0);
XSetFunction(dpy, scorefontgc, GXcopyInverted);
cp = (char*)getenv("SCOREFONT");
if (!cp) cp = "fcor-20";
scorefont = XLoadQueryFont(dpy,cp);
if (scorefont == 0) {
fprintf(stderr,"Can't load (scorefont). Bye!\n");
exit(1);
}
scorefonthigh = scorefont->max_bounds.ascent+msgfont->max_bounds.descent;
scorefonta = msgfont->max_bounds.ascent;
XSetFont(dpy,scorefontgc, scorefont->fid);
}
display_monster(mx)
{
Pixmap m = symbol_pixmap((mx != (-1) ? 'M' : ' '));
GC mgc = symbol_gc((mx != (-1) ? 'M' : ' '));
int x1 = ICON_WIDE * 12 + 54;
int x2 = x1 + (ICON_WIDE) + 6;
int y1 = scorefonthigh * 10 + 10;
int y2 = y1 + (ICON_HIGH) + 6;
XDrawLine(dpy, win, linegc, x1, y1, x2, y1);
XDrawLine(dpy, win, linegc, x2, y1, x2, y2);
XDrawLine(dpy, win, linegc, x2, y2, x1, y2);
XDrawLine(dpy, win, linegc, x1, y2, x1, y1);
XCopyArea(dpy, m, win, mgc, 0, 0, ICON_WIDE, ICON_HIGH,
x1 + 3, y1 + 3);
/* score_message(9," Monster Detector"); */
}
table_message(y,fmt,s1,s2,s3,s4,s5,s6,s7,s8)
char *fmt,*s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8;
{
char buf[256];
sprintf(buf,fmt,s1,s2,s3,s4,s5,s6,s7,s8);
XDrawImageString(dpy, win, tablegc,30,
(tablefonthigh*y)+10+tablefonta, buf, strlen(buf));
}
message(y,fmt,s1,s2,s3,s4,s5,s6,s7,s8)
char *fmt,*s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8;
{
char buf[256];
sprintf(buf,fmt,s1,s2,s3,s4,s5,s6,s7,s8);
XDrawImageString(dpy, win, msgfontgc,5,
(msgfonthigh*y)+(ICON_HIGH*7)+20+msgfonta, buf, strlen(buf));
}
erase_message(n)
{
/* fprintf(stderr,"XClearArea: %d %d %d %d\n",
5, (msgfonthigh*n)+(ICON_HIGH*7)+20,ICON_WIDE*11+10,msgfonthigh); */
XClearArea(dpy, win, 5, (msgfonthigh*n)+(ICON_HIGH*7)+20,
ICON_WIDE * 11 + 10, msgfonthigh, 0);
}
score_message(y,fmt,s1,s2,s3,s4,s5,s6,s7,s8)
char *fmt,*s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8;
{
char buf[256];
sprintf(buf,fmt,s1,s2,s3,s4,s5,s6,s7,s8);
XDrawImageString(dpy, win, scorefontgc, ICON_WIDE*11+20,
scorefonthigh*y+10+scorefonta,
buf, strlen(buf));
}
XBeep() /* There has to be a better way to do this.. */
{
XFlush(dpy); printf("\07"); fflush(stdout);
}
/* takes over the standard getchar */
getchar(sx, sy, frow, score, nf, diamonds, num, maxmoves, mx)
char (*frow)[ROWLEN+1];
int *score;
{
XEvent event, ev;
int i;
char buf[3];
/* printf("In getchar\n"); */
while (1) {
XNextEvent(dpy, &(event));
switch(event.type) {
case Expose:
if (event.xexpose.count != 0) {
/* fprintf(stderr,"xwanderer: %d expose events to follow\n",
event.xexpose.count); */
/* XXX - anyone want to optimize this? */
/* what we do here is look at the number of expose
* events that are supposed to follow this one
* and throw them away then we do a big redraw
*/
for (i = 0; i < event.xexpose.count != 0; i++) {
XPeekEvent(dpy, &(ev)); /* peek */
if (ev.type != Expose) /* is the event expose? */
break; /* yep, we'll proc. later */
XNextEvent(dpy,&ev); /* nope, toss event */
}
}
if (sx != (-1)) {
do_repaint = 1;
if (!tinymode)
display(sx,sy,frow,*score);
else drawmap(frow,1);
repaint_score(*score, nf, diamonds, num, maxmoves, mx);
}
break;
case KeyPress:
buf[0] = 0;
XLookupString(&(event), buf, 1, NULL, NULL);
buf[1] = 0;
/* printf("buf[0] = %c %d\n", buf[0], buf[0]); */
if (buf[0] == 13) buf[0] = 10;
if (buf[0] == 12) {
do_repaint = 1;
if (sx != (-1))
if (tinymode) drawmap(frow,1);
else
display(sx,sy,frow,*score);
} else if (buf[0] != 0) return(buf[0]);
break;
}
}
}
repaint_score(score, nf, diamonds, num, maxmoves, mx)
{
score_message(0,"Score Diamonds");
score_message(1," Found Total");
score_message(2,"%7d %3d %3d ", score, nf, diamonds);
score_message(6,"Current Screen %d ",num);
if (maxmoves != -1)
score_message(15,"Moves Remaining = %d ", maxmoves);
else
score_message(15," Unlimited moves ");
display_monster(mx);
}
#endif