home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / vmsnet / sources / games / 458 < prev    next >
Encoding:
Text File  |  1992-11-20  |  14.3 KB  |  550 lines

  1. Newsgroups: vmsnet.sources.games
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!raven.alaska.edu!acad2.alaska.edu!asdmf
  3. From: asdmf@acad2.alaska.edu
  4. Subject: Vmsnetrek 46/47
  5. Message-ID: <1992Nov20.211109.1@acad2.alaska.edu>
  6. Lines: 538
  7. Sender: news@raven.alaska.edu (USENET News System)
  8. Nntp-Posting-Host: acad2.alaska.edu
  9. Organization: University of Alaska
  10. Date: Sat, 21 Nov 1992 01:11:09 GMT
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 46 -+-+-+-+-+-+-+-+
  13. X`009`009break;
  14. X`009    case GREY:
  15. X`009`009foo.pixel=pixel`124planes`0910`093`124planes`0911`093;
  16. X`009`009break;
  17. X`009    case GREEN:
  18. X`009`009foo.pixel=pixel`124planes`0911`093`124planes`0912`093;
  19. X`009`009break;
  20. X`009    `125
  21. X`009    XStoreColor(W_Display, W_Colormap, &foo);
  22. X`009    colortable`091i`093.pixelValue = foo.pixel;
  23. X`009    colortable`091i`093.pixmap = XCreatePixmapFromBitmapData(W_Display,
  24. X`009`009W_Root, solid, TILESIDE, TILESIDE, foo.pixel, foo.pixel,
  25. X`009`009DefaultDepth(W_Display, W_Screen));
  26. X`009`125
  27. X    `125
  28. X    for (i=0; i<NCOLORS; i++) `123
  29. X`009for (j=0; j<FONTS+1; j++) `123
  30. X`009    XSetForeground(W_Display, colortable`091i`093.contexts`091j`093,`032
  31. X`009`009colortable`091i`093.pixelValue);
  32. X`009    XSetBackground(W_Display, colortable`091i`093.contexts`091j`093,
  33. X`009`009colortable`091W_Black`093.pixelValue);
  34. X`009`125
  35. X    `125
  36. X`125
  37. X
  38. XW_Window W_MakeWindow(name,x,y,width,height,parent,border,color)
  39. Xchar *name;
  40. Xint x,y,width,height;
  41. XW_Window parent;
  42. Xint border;
  43. XW_Color color;
  44. X`123
  45. X    struct window *newwin;
  46. X    Window wparent;
  47. X    XSetWindowAttributes attrs;
  48. X`009
  49. X#ifdef DEBUG
  50. X    printf("New window...\n");
  51. X#endif
  52. X    checkGeometry(name, &x, &y, &width, &height);
  53. X    checkParent(name, &parent);
  54. X    wparent=W_Void2Window(parent)->window;
  55. X    attrs.override_redirect=False;
  56. X    attrs.border_pixel=colortable`091color`093.pixelValue;
  57. X    attrs.event_mask=KeyPressMask`124ButtonPressMask`124ExposureMask;
  58. X    attrs.background_pixel=colortable`091W_Black`093.pixelValue;
  59. X    attrs.do_not_propagate_mask=KeyPressMask`124ButtonPressMask`124ExposureM
  60. Vask;
  61. X    newwin=newWindow(
  62. X`009XCreateWindow(W_Display, wparent, x, y, width, height, border,
  63. X`009    CopyFromParent, InputOutput, CopyFromParent,`032
  64. X`009    CWBackPixel`124CWEventMask`124CWOverrideRedirect`124CWBorderPixel,`0
  65. V32
  66. X`009    &attrs),
  67. X`009WIN_GRAPH);
  68. X    XSetClassHint(W_Display, newwin->window, &class_hint);
  69. X    XSetWMHints(W_Display, newwin->window, &wm_hint);
  70. X    newwin->name=strdup(name);
  71. X    newwin->width=width;
  72. X    newwin->height=height;
  73. X    if (checkMapped(name)) W_MapWindow(W_Window2Void(newwin));
  74. X
  75. X#ifdef DEBUG
  76. X    printf("New graphics window %d, child of %d\n", newwin, parent);
  77. X#endif
  78. X
  79. X    return(W_Window2Void(newwin));
  80. X`125
  81. X
  82. Xvoid W_ChangeBorder(window, color)
  83. XW_Window window;
  84. Xint color;
  85. X`123
  86. X#ifdef DEBUG
  87. X    printf("Changing border of %d\n", window);
  88. X#endif
  89. X`009
  90. X    XSetWindowBorderPixmap(W_Display, W_Void2Window(window)->window,
  91. X`009colortable`091color`093.pixmap);
  92. X`125
  93. X
  94. Xvoid W_WarpPointer(window)
  95. XW_Window window;
  96. X`123
  97. X  XWarpPointer(W_Display, None, W_Void2Window(window)->window, 0, 0, 0, 0,
  98. X`009       10,10);
  99. X`125
  100. X
  101. Xvoid W_MapWindow(window)
  102. XW_Window window;
  103. X`123
  104. X    struct window *win;
  105. X
  106. X#ifdef DEBUG
  107. X    printf("Mapping %d\n", window);
  108. X#endif
  109. X    win=W_Void2Window(window);
  110. X    if (win->mapped) return;
  111. X    win->mapped=1;
  112. X    XMapRaised(W_Display, win->window);
  113. X`125
  114. X
  115. Xvoid W_UnmapWindow(window)
  116. XW_Window window;
  117. X`123
  118. X    struct window *win;
  119. X
  120. X#ifdef DEBUG
  121. X    printf("UnMapping %d\n", window);
  122. X#endif
  123. X    win=W_Void2Window(window);
  124. X    if (win->mapped==0) return;
  125. X    win->mapped=0;
  126. X    XUnmapWindow(W_Display, win->window);
  127. X`125
  128. X
  129. Xint W_IsMapped(window)
  130. XW_Window window;
  131. X`123
  132. X    struct window *win;
  133. X
  134. X    win=W_Void2Window(window);
  135. X    if (win==NULL) return(0);
  136. X    return(win->mapped);
  137. X`125
  138. X
  139. Xvoid W_ClearArea(window, x, y, width, height, color)
  140. XW_Window window;
  141. Xint x, y, width, height;
  142. XW_Color color;
  143. X`123
  144. X    struct window *win;
  145. X
  146. X#ifdef DEBUG
  147. X    printf("Clearing (%d %d) x (%d %d) with %d on %d\n", x,y,width,height,
  148. X`009color,window);
  149. X#endif
  150. X    win=W_Void2Window(window);
  151. X    switch(win->type) `123
  152. X    case WIN_GRAPH:
  153. X`009XFillRectangle(W_Display, win->window, colortable`091color`093.contexts`
  154. V0910`093,
  155. X`009    x, y, width, height);
  156. X`009break;
  157. X    default:
  158. X`009XFillRectangle(W_Display, win->window, colortable`091color`093.contexts`
  159. V0910`093,
  160. X`009    WIN_EDGE+x*W_Textwidth, MENU_PAD+y*W_Textheight,`032
  161. X`009    width*W_Textwidth, height*W_Textheight);
  162. X`009break;
  163. X    `125
  164. X`125
  165. X
  166. Xvoid W_ClearWindow(window)
  167. XW_Window window;
  168. X`123
  169. X#ifdef DEBUG
  170. X    printf("Clearing %d\n", window);
  171. X#endif
  172. X    XClearWindow(W_Display, W_Void2Window(window)->window);
  173. X`125
  174. X
  175. Xint W_EventsPending()
  176. X`123
  177. X    if (W_isEvent) return(1);
  178. X    while (XPending(W_Display)) `123
  179. X`009if (W_SpNextEvent(&W_myevent)) `123
  180. X`009    W_isEvent=1;
  181. X`009    return(1);
  182. X`009`125
  183. X    `125
  184. X    return(0);
  185. X`125
  186. X
  187. Xvoid W_NextEvent(wevent)
  188. XW_Event *wevent;
  189. X`123
  190. X    if (W_isEvent) `123
  191. X`009*wevent=W_myevent;
  192. X`009W_isEvent=0;
  193. X`009return;
  194. X    `125
  195. X    while (W_SpNextEvent(wevent)==0);
  196. X`125
  197. X
  198. Xint W_SpNextEvent(wevent)
  199. XW_Event *wevent;
  200. X`123
  201. X    XEvent event;
  202. X    XKeyEvent *key;
  203. X    XButtonEvent *button;
  204. X    XExposeEvent *expose;
  205. X    XResizeRequestEvent *resize;
  206. X    char ch;
  207. X    int nchars;
  208. X    struct window *win;
  209. X
  210. X#ifdef DEBUG
  211. X    printf("Getting an event...\n");
  212. X#endif
  213. X    key=(XKeyEvent *) &event;
  214. X    button=(XButtonEvent *) &event;
  215. X    expose=(XExposeEvent *) &event;
  216. X    resize=(XResizeRequestEvent *) &event;
  217. X    for (;;) `123
  218. X`009XNextEvent(W_Display, &event);
  219. X`009win=findWindow(key->window);
  220. X        if (win==NULL) return(0);
  221. X`009if ((event.type==KeyPress `124`124 event.type==ButtonPress) &&
  222. X`009    win->type == WIN_MENU) `123
  223. X`009    if (key->y % (W_Textheight + MENU_PAD*2+MENU_BAR) >=`032
  224. X`009`009W_Textheight+MENU_PAD*2) return(0);
  225. X`009    key->y=key->y/(W_Textheight+MENU_PAD*2+MENU_BAR);
  226. X`009`125
  227. X`009switch((int) event.type) `123
  228. X`009case KeyPress:
  229. X`009    if (XLookupString(key,&ch,1,NULL,NULL)>0) `123
  230. X`009`009wevent->type=W_EV_KEY;
  231. X`009`009wevent->Window=W_Window2Void(win);
  232. X`009`009wevent->x=key->x;
  233. X`009`009wevent->y=key->y;
  234. X`009`009wevent->key=ch;
  235. X`009`009return(1);
  236. X`009    `125
  237. X`009    return(0);
  238. X`009    break;
  239. X`009case ButtonPress:
  240. X`009    wevent->type=W_EV_BUTTON;
  241. X`009    wevent->Window=W_Window2Void(win);
  242. X`009    wevent->x=button->x;
  243. X`009    wevent->y=button->y;
  244. X`009    switch(button->button & 0xf) `123
  245. X`009    case Button3:
  246. X`009`009wevent->key=W_RBUTTON;
  247. X`009`009break;
  248. X`009    case Button1:
  249. X`009`009wevent->key=W_LBUTTON;
  250. X`009`009break;
  251. X`009    case Button2:
  252. X`009`009wevent->key=W_MBUTTON;
  253. X`009`009break;
  254. X`009    `125
  255. X`009    return(1);
  256. X`009case Expose:
  257. X`009    if (expose->count != 0) return(0);
  258. X`009    if (win->type == WIN_SCROLL) `123
  259. X`009`009redrawScrolling(win);
  260. X`009`009return(0);
  261. X`009    `125
  262. X`009    if (win->type == WIN_MENU) `123
  263. X`009`009redrawMenu(win);
  264. X`009`009return(0);
  265. X`009    `125
  266. X`009    wevent->type=W_EV_EXPOSE;
  267. X`009    wevent->Window=W_Window2Void(win);
  268. X`009    return(1);
  269. X`009case ResizeRequest:
  270. X`009    resizeScrolling(win, resize->width, resize->height);
  271. X`009    break;
  272. X`009default:
  273. X`009    return(0);
  274. X`009    break;
  275. X`009`125
  276. X    `125
  277. X`125
  278. X
  279. Xvoid W_MakeLine(window, x0, y0, x1, y1, color)
  280. XW_Window window;
  281. Xint x0, y0, x1, y1;
  282. XW_Color color;
  283. X`123
  284. X    Window win;
  285. X
  286. X#ifdef DEBUG
  287. X    printf("Line on %d\n", window);
  288. X#endif
  289. X    win=W_Void2Window(window)->window;
  290. X    XDrawLine(W_Display, win, colortable`091color`093.contexts`0910`093, x0,
  291. V y0, x1, y1);
  292. X`125
  293. X
  294. Xvoid W_WriteText(window, x, y, color, str, len, font)
  295. XW_Window window;
  296. Xint x, y,len;
  297. XW_Color color;
  298. XW_Font font;
  299. Xchar *str;
  300. X`123
  301. X    struct window *win;
  302. X    int addr;
  303. X
  304. X#ifdef DEBUG
  305. X    printf("Text for %d @ (%d, %d) in %d: `091%s`093\n", window, x,y,color,s
  306. Vtr);
  307. X#endif
  308. X    win=W_Void2Window(window);
  309. X    switch(win->type) `123
  310. X    case WIN_GRAPH:
  311. X`009addr=fonts`091fontNum(font)`093.baseline;
  312. X`009XDrawImageString(W_Display, win->window,`032
  313. X`009    colortable`091color`093.contexts`091fontNum(font)`093,x,y+addr,str,l
  314. Ven);
  315. X`009break;
  316. X    case WIN_SCROLL:
  317. X`009XCopyArea(W_Display, win->window, win->window,
  318. X`009    colortable`091W_White`093.contexts`0910`093, WIN_EDGE, MENU_PAD+W_Te
  319. Vxtheight,
  320. X`009    win->width*W_Textwidth, (win->height-1)*W_Textheight,
  321. X`009    WIN_EDGE, MENU_PAD);
  322. X`009XClearArea(W_Display, win->window,`032
  323. X`009    WIN_EDGE, MENU_PAD+W_Textheight*(win->height-1),
  324. X`009    W_Textwidth*win->width, W_Textheight, False);
  325. X`009XDrawImageString(W_Display, win->window,
  326. X`009    colortable`091color`093.contexts`0911`093,
  327. X`009    WIN_EDGE, MENU_PAD+W_Textheight*(win->height-1)+fonts`0911`093.basel
  328. Vine,
  329. X`009    str, len);
  330. X`009AddToScrolling(win, color, str, len);
  331. X`009break;
  332. X    case WIN_MENU:
  333. X`009changeMenuItem(win, y, str, len, color);
  334. X`009break;
  335. X    default:
  336. X`009addr=fonts`091fontNum(font)`093.baseline;
  337. X`009XDrawImageString(W_Display, win->window,
  338. X`009    colortable`091color`093.contexts`091fontNum(font)`093,
  339. X`009    x*W_Textwidth+WIN_EDGE, MENU_PAD+y*W_Textheight+addr,
  340. X`009    str, len);
  341. X`009break;
  342. X    `125
  343. X`125
  344. X
  345. Xvoid W_MaskText(window, x, y, color, str, len, font)
  346. XW_Window window;
  347. Xint x, y,len;
  348. XW_Color color;
  349. XW_Font font;
  350. Xchar *str;
  351. X`123
  352. X    struct window *win;
  353. X    int addr;
  354. X
  355. X    addr=fonts`091fontNum(font)`093.baseline;
  356. X#ifdef DEBUG
  357. X    printf("TextMask for %d @ (%d, %d) in %d: `091%s`093\n", window, x,y,col
  358. Vor,str);
  359. X#endif
  360. X    win=W_Void2Window(window);
  361. X    XDrawString(W_Display, win->window,`032
  362. X`009colortable`091color`093.contexts`091fontNum(font)`093, x,y+addr, str, le
  363. Vn);
  364. X`125
  365. X
  366. XW_Icon W_StoreBitmap(width, height, data, window)
  367. Xint width, height;
  368. XW_Window window;
  369. Xunsigned char *data;
  370. X`123
  371. X    struct icon *newicon;
  372. X    struct window *win;
  373. X
  374. X#ifdef DEBUG
  375. X    printf("Storing bitmap for %d (%d x %d)\n", window,width,height);
  376. X    fflush(stdout);
  377. X#endif
  378. X    win=W_Void2Window(window);
  379. X    newicon=(struct icon *) malloc(sizeof(struct icon));
  380. X    newicon->width=width;
  381. X    newicon->height=height;
  382. X    newicon->bitmap=XCreateBitmapFromData(W_Display, win->window,
  383. X`009data, width, height);
  384. X    newicon->window=win->window;
  385. X    newicon->pixmap=0;
  386. X
  387. X    return(W_Icon2Void(newicon));
  388. X`125
  389. X
  390. Xvoid W_WriteBitmap(x, y, bit, color)
  391. Xint x,y;
  392. XW_Icon bit;
  393. XW_Color color;
  394. X`123
  395. X    struct icon *icon;
  396. X
  397. X    icon=W_Void2Icon(bit);
  398. X#ifdef DEBUG
  399. X    printf("Writing bitmap to %d\n", icon->window);
  400. X#endif
  401. X    XCopyPlane(W_Display, icon->bitmap, icon->window,
  402. X`009colortable`091color`093.contexts`091BITGC`093, 0, 0, icon->width, icon->
  403. Vheight,
  404. X`009x, y, 1);
  405. X`125
  406. X
  407. Xvoid W_TileWindow(window, bit)
  408. XW_Window window;
  409. XW_Icon bit;
  410. X`123
  411. X    Window win;
  412. X    struct icon *icon;
  413. X
  414. X#ifdef DEBUG
  415. X    printf("Tiling window %d\n", window);
  416. X#endif
  417. X    icon=W_Void2Icon(bit);
  418. X    win=W_Void2Window(window)->window;
  419. X
  420. X    if (icon->pixmap==0) `123
  421. X`009icon->pixmap=XCreatePixmap(W_Display, W_Root,
  422. X`009    icon->width, icon->height, DefaultDepth(W_Display, W_Screen));
  423. X`009XCopyPlane(W_Display, icon->bitmap, icon->pixmap,`032
  424. X`009    colortable`091W_White`093.contexts`0910`093, 0, 0, icon->width, icon
  425. V->height,
  426. X`009    0, 0, 1);
  427. X    `125
  428. X    XSetWindowBackgroundPixmap(W_Display, win, icon->pixmap);
  429. X    XClearWindow(W_Display, win);
  430. X
  431. X/*
  432. X    if (icon->pixmap==0) `123
  433. X`009icon->pixmap=XMakePixmap(icon->bitmap, colortable`091W_White`093.pixelVa
  434. Vlue,
  435. X`009    colortable`091W_Black`093.pixelValue);
  436. X    `125
  437. X    XChangeBackground(win, icon->pixmap);
  438. X    XClear(win);
  439. X */
  440. X`125
  441. X
  442. Xvoid W_UnTileWindow(window)
  443. XW_Window window;
  444. X`123
  445. X    Window win;
  446. X
  447. X#ifdef DEBUG
  448. X    printf("Untiling window %d\n", window);
  449. X#endif
  450. X    win=W_Void2Window(window)->window;
  451. X
  452. X    XSetWindowBackground(W_Display, win, colortable`091W_Black`093.pixelValu
  453. Ve);
  454. X    XClearWindow(W_Display, win);
  455. X`125
  456. X
  457. XW_Window W_MakeTextWindow(name,x,y,width,height,parent,border)
  458. Xchar *name;
  459. Xint x,y,width,height;
  460. XW_Window parent;
  461. Xint border;
  462. X`123
  463. X    struct window *newwin;
  464. X    Window wparent;
  465. X    XSetWindowAttributes attrs;
  466. X`009
  467. X#ifdef DEBUG
  468. X    printf("New window...\n");
  469. X#endif
  470. X    checkGeometry(name, &x, &y, &width, &height);
  471. X    checkParent(name, &parent);
  472. X    attrs.override_redirect=False;
  473. X    attrs.border_pixel=colortable`091W_White`093.pixelValue;
  474. X    attrs.event_mask=ExposureMask;
  475. X    attrs.background_pixel=colortable`091W_Black`093.pixelValue;
  476. X    attrs.do_not_propagate_mask=ExposureMask;
  477. X    wparent=W_Void2Window(parent)->window;
  478. X    newwin=newWindow(
  479. X`009XCreateWindow(W_Display, wparent, x, y,`032
  480. X`009    width*W_Textwidth+WIN_EDGE*2, MENU_PAD*2+height*W_Textheight,`032
  481. X`009    border, CopyFromParent, InputOutput, CopyFromParent,
  482. X`009    CWBackPixel`124CWEventMask`124
  483. X`009    CWOverrideRedirect`124CWBorderPixel,`032
  484. X`009    &attrs),
  485. X`009WIN_TEXT);
  486. X    XSetClassHint(W_Display, newwin->window, &class_hint);
  487. X    XSetWMHints(W_Display, newwin->window, &wm_hint);
  488. X    newwin->name=strdup(name);
  489. X    newwin->width=width;
  490. X    newwin->height=height;
  491. X    if (checkMapped(name)) W_MapWindow(W_Window2Void(newwin));
  492. X#ifdef DEBUG
  493. X    printf("New text window %d, child of %d\n", newwin, parent);
  494. X#endif
  495. X    return(W_Window2Void(newwin));
  496. X`125
  497. X
  498. Xstruct window *newWindow(window, type)
  499. XWindow window;
  500. Xint type;
  501. X`123
  502. X    struct window *newwin;
  503. X
  504. X    newwin=(struct window *) malloc(sizeof(struct window));
  505. X    newwin->window=window;
  506. X    newwin->type=type;
  507. X    newwin->mapped=0;
  508. X    addToHash(newwin);
  509. X    return(newwin);
  510. X`125
  511. X
  512. Xstruct window *findWindow(window)
  513. XWindow window;
  514. X`123
  515. X    struct windowlist *entry;
  516. X
  517. X    entry=hashtable`091hash(window)`093;
  518. X    while (entry!=NULL) `123
  519. X`009if (entry->window->window == window) return(entry->window);
  520. X`009entry=entry->next;
  521. X    `125
  522. X    return(NULL);
  523. X`125
  524. X
  525. XaddToHash(win)
  526. Xstruct window *win;
  527. X`123
  528. X    struct windowlist **new;
  529. X
  530. X#ifdef DEBUG
  531. X    printf("Adding to %d\n", hash(win->window));
  532. X#endif
  533. X    new= &hashtable`091hash(win->window)`093;
  534. X    while (*new != NULL) `123
  535. X`009new= &((*new)->next);
  536. X    `125
  537. X    *new=(struct windowlist *) malloc(sizeof(struct windowlist));
  538. X    (*new)->next=NULL;
  539. X    (*new)->window=win;
  540. X`125
  541. X
  542. XW_Window W_MakeScrollingWindow(name,x,y,width,height,parent,border)
  543. Xchar *name;
  544. Xint x,y,width,height;
  545. XW_Window parent;
  546. Xint border;
  547. X`123
  548. X    struct window *newwin;
  549. +-+-+-+-+-+-+-+-  END  OF PART 46 +-+-+-+-+-+-+-+-
  550.