Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2006/0112/1

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


mahjongg tweaks
 [jmk] --rw-rw-r-- M 368016 jmk sys 5373 Jan 12 10:39 sys/man/1/games
	/n/sourcesdump/2006/0112/plan9/sys/man/1/games:1,6 - 
	/n/sourcesdump/2006/0113/plan9/sys/man/1/games:1,6
	  .TH GAMES 1
	  .SH NAME
	- mahjongg, sokoban, sudoku \- time wasters
	+ 4s, 5s, juggle, mahjongg, sokoban, sudoku \- time wasters
	  .SH SYNOPSIS
	  .B games/4s
	  .br
	/n/sourcesdump/2006/0112/plan9/sys/man/1/games:22,27 - 
	/n/sourcesdump/2006/0113/plan9/sys/man/1/games:22,29
	  [
	  .B -c
	  ] [
	+ .B -f
	+ ] [
	  .B -b
	  .I background
	  ] [
	/n/sourcesdump/2006/0112/plan9/sys/man/1/games:47,54 - 
	/n/sourcesdump/2006/0113/plan9/sys/man/1/games:49,54
	  Move tiles left or right by moving the mouse.
	  Rotate tiles with buttons 1 and 3.
	  Drop tiles for more points with button 2 or the space bar.
	- Move the mouse out of or back into the play area to
	- suspend or resume the game.
	  Keys
	  .LR a
	  and 
	/n/sourcesdump/2006/0112/plan9/sys/man/1/games:107,114 - 
	/n/sourcesdump/2006/0113/plan9/sys/man/1/games:107,116
	  .RB (-l)
	  images;
	  .RB -c
	- selects a true-color buffer image, use with
	- drawterm or in case selecting a tile obscures it completely.
	+ selects a true-color buffer image, for use with
	+ drawterm or in case selecting a tile obscures it completely;
	+ .RB -f
	+ causes mahjongg to indicate non-blocked tiles on mouse-over.
	  The 
	  .LR N
	  key will generate a new level, 
 [jmk] --rw-rw-r-- M 368016 jmk sys 7054 Jan 12 10:39 sys/src/games/mahjongg/graphics.c
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/graphics.c:84,89 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/graphics.c:84,92
	  	if(level.board[d][x][y].clicked)
	  		draw(img, r, selected, nil, ZP);
	  
	+ 	if(level.l.d == d && eqpt(level.l.p, Pt(x, y)))
	+ 		border(img, r, 2, litbrdr, level.board[d][x][y].start);
	+ 
	  	/* looks better without borders, uncomment to check it out with'em */
	  //	r = Rpt(r.min, addpt(r.min, Pt(Tilex, Tiley)));
	  //	draw(img, r, brdr, nil, ZP);
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/graphics.c:248,253 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/graphics.c:251,320
	  		drawlevel();
	  		if(!canmove())
	  			done();
	+ 	}
	+ }
	+ 
	+ void
	+ light(Point coord)
	+ {
	+ 	Point p;
	+ 	int d;
	+ 
	+ 	/* ugly on purpose */
	+ 
	+ 	for(d = Depth - 1; d >= 0; d--) {
	+ 		p = Pt((coord.x + TileDxy*d)/(Facex/2), (coord.y + TileDxy*d)/(Facey/2));
	+ 		switch(level.board[d][p.x][p.y].which) {
	+ 		case 0:
	+ 			break;
	+ 		case 1:
	+ 			goto Found;
	+ 		case 2:
	+ 			p = Pt(p.x-1, p.y);
	+ 			goto Found;
	+ 		case 3:
	+ 			p = Pt(p.x-1, p.y-1);
	+ 			goto Found;
	+ 		case 4:
	+ 			p = Pt(p.x, p.y-1);
	+ 			goto Found;
	+ 		}
	+ 	}
	+ 
	+ 	return;
	+ 
	+ Found:
	+ 	if(level.l.d == d && eqpt(level.l.p, p))
	+ 		return;
	+ 
	+ 	if(freeup(d, p) && (freeleft(d, p) || freeright(d, p))) {
	+ 		Point tmpp;
	+ 		int tmpd;
	+ 
	+ 		tmpd = level.l.d;
	+ 		tmpp = level.l.p;
	+ 
	+ 		level.l.d = d;
	+ 		level.l.p = p;
	+ 		drawbrick(d, p.x, p.y);
	+ 
	+ 		/* clean up the previously lit brick */
	+ 		if(tmpd != -1 && level.board[tmpd][tmpp.x][tmpp.y].which == 1) 
	+ 			drawbrick(tmpd, tmpp.x, tmpp.y);
	+ 			
	+ 		draw(screen, screen->r, img, nil, ZP);
	+ 		flushimage(display, 1);
	+ 	} else if(level.l.d != -1) {
	+ 		d = level.l.d;
	+ 		p = level.l.p;
	+ 		level.l.d = -1;
	+ 		level.l.p = Pt(0, 0);
	+ 
	+ 		if(level.board[d][p.x][p.y].which == 1) {
	+ 			drawbrick(d, p.x, p.y);
	+ 			draw(screen, screen->r, img, nil, ZP);
	+ 			flushimage(display, 1);
	+ 		}
	  	}
	  }
	  
 [jmk] --rw-rw-r-- M 368016 jmk sys 2560 Jan 12 10:39 sys/src/games/mahjongg/level.c
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/level.c:145,150 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/level.c:145,152
	  
	  	orig.c.d = -1;
	  	orig.c.p = Pt(0, 0);
	+ 	orig.l.d = -1;
	+ 	orig.l.p = Pt(0, 0);
	  	orig.done = 0;
	  	level = orig;
	  }
 [jmk] --rw-rw-r-- M 368016 jmk sys 3631 Jan 12 10:39 sys/src/games/mahjongg/mahjongg.c
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.c:14,20 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.c:14,22
	  char *deflayout = "/sys/games/lib/mahjongg/layouts/default.layout";
	  ulong defchan;
	  
	+ int trace;
	  
	+ 
	  char *buttons[] = 
	  {
	  	"new",
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.c:32,38 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.c:34,40
	  void
	  usage(char *progname)
	  {
	- 	fprint(2, "usage: %s [-b background] [-l layout] [-t tileset] -c\n", progname);
	+ 	fprint(2, "usage: %s [-b background] [-l layout] [-t tileset] [-c] [-f]\n", progname);
	  	exits("usage");
	  }
	  
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.c:74,79 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.c:76,82
	  	Rectangle one = Rect(0, 0, 1, 1);
	  	
	  	selected = eallocimage(one, 1, RGBA32, setalpha(DPalebluegreen, 0x5f));
	+ 	litbrdr = eallocimage(one, 1, RGBA32, DGreen);
	  	img = eallocimage(Rect(0, 0, Sizex, Sizey), 0, defchan ? defchan : screen->chan, DBlack);
	  
	  	background = eloadfile(defbackgr);
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.c:104,109 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.c:107,115
	  	ARGBEGIN{
	  	case 'h':
	  		usage(argv0);
	+ 	case 'f':
	+ 		trace = 1;
	+ 		break;
	  	case 'b':
	  		defbackgr = EARGF(usage(argv0));
	  		break;
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.c:148,155 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.c:154,164
	  					clickety = 1;
	  					clicked(subpt(m.xy, addpt(screen->r.min, Pt(30, 30))));
	  				}
	- 			} else 
	+ 			} else {
	  				clickety = 0;
	+ 				if(trace)
	+ 					light(subpt(m.xy, addpt(screen->r.min, Pt(30, 30))));
	+ 			}
	  			if(m.buttons&2) {
	  				/* nothing here for the moment */
	  			}
 [jmk] --rw-rw-r-- M 368016 jmk sys 1687 Jan 12 10:39 sys/src/games/mahjongg/mahjongg.h
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.h:55,60 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.h:55,61
	  typedef struct {
	  	Brick 	board[Depth][Lx][Ly];
	  	Click		c; 		/* player has a brick selected */
	+ 	Click		l; 		/* mouse-over-brick indicator */
	  	int			done;
	  	int 		remaining;
	  } Level;
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.h:69,74 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.h:70,76
	  Image *mask;
	  Image *background;
	  Image *selected;
	+ Image *litbrdr;
	  Image *gameover;
	  
	  /* graphics.c */
	/n/sourcesdump/2006/0112/plan9/sys/src/games/mahjongg/mahjongg.h:75,80 - 
	/n/sourcesdump/2006/0113/plan9/sys/src/games/mahjongg/mahjongg.h:77,83
	  void drawlevel(void);
	  void resize(Point);
	  void clicked(Point);
	+ void light(Point);
	  void hint(void);
	  void done(void);
	  void clearlevel(void);


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.