Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/dab if 0 is used for the dimensions, compute the maxim...



details:   https://anonhg.NetBSD.org/src/rev/9603ce68835a
branches:  trunk
changeset: 781916:9603ce68835a
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 06 19:39:51 2012 +0000

description:
if 0 is used for the dimensions, compute the maximum size.

diffstat:

 games/dab/dab.6      |   8 ++++++--
 games/dab/main.cc    |   6 +++---
 games/dab/ttyscrn.cc |  14 +++++++++-----
 games/dab/ttyscrn.h  |   4 ++--
 4 files changed, 20 insertions(+), 12 deletions(-)

diffs (119 lines):

diff -r b54e9703616d -r 9603ce68835a games/dab/dab.6
--- a/games/dab/dab.6   Sat Oct 06 19:23:01 2012 +0000
+++ b/games/dab/dab.6   Sat Oct 06 19:39:51 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: dab.6,v 1.5 2010/01/15 19:39:10 joerg Exp $
+.\"    $NetBSD: dab.6,v 1.6 2012/10/06 19:39:51 christos Exp $
 .\"
 .\" Copyright (c) 2003 Thomas Klausner.
 .\"
@@ -22,7 +22,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 24, 2003
+.Dd October 7, 2012
 .Dt DAB 6
 .Os
 .Sh NAME
@@ -95,6 +95,10 @@
 .Ar ydim
 define the size of the board in the x and y
 dimensions.
+If the dimensions specified are
+.Dv 0
+then the maximum dimensions for the size of the screen are
+used.
 .Sh SEE ALSO
 .Rs
 .%A Elwyn R. Berlekamp
diff -r b54e9703616d -r 9603ce68835a games/dab/main.cc
--- a/games/dab/main.cc Sat Oct 06 19:23:01 2012 +0000
+++ b/games/dab/main.cc Sat Oct 06 19:39:51 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.cc,v 1.5 2008/04/28 20:22:54 martin Exp $ */
+/*     $NetBSD: main.cc,v 1.6 2012/10/06 19:39:51 christos Exp $       */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  * main.C: Main dots program
  */
 #include "defs.h"
-RCSID("$NetBSD: main.cc,v 1.5 2008/04/28 20:22:54 martin Exp $")
+RCSID("$NetBSD: main.cc,v 1.6 2012/10/06 19:39:51 christos Exp $")
 
 #include <stdio.h>
 #include <unistd.h>
@@ -168,7 +168,7 @@
        }
     }
 
-    sc = TTYSCRN::create(acs, ny, nx);
+    sc = TTYSCRN::create(acs, &ny, &nx);
     if (sc == NULL)
        ::errx(1, "Dimensions too large for current screen.");
 
diff -r b54e9703616d -r 9603ce68835a games/dab/ttyscrn.cc
--- a/games/dab/ttyscrn.cc      Sat Oct 06 19:23:01 2012 +0000
+++ b/games/dab/ttyscrn.cc      Sat Oct 06 19:39:51 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttyscrn.cc,v 1.4 2008/04/28 20:22:54 martin Exp $      */
+/*     $NetBSD: ttyscrn.cc,v 1.5 2012/10/06 19:39:51 christos Exp $    */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include "defs.h"
-RCSID("$NetBSD: ttyscrn.cc,v 1.4 2008/04/28 20:22:54 martin Exp $")
+RCSID("$NetBSD: ttyscrn.cc,v 1.5 2012/10/06 19:39:51 christos Exp $")
 
 #include <stdio.h>
 #include <curses.h>
@@ -191,7 +191,7 @@
     mvwprintw(stdscr, _sy + TTYSCRN::offsties, _sx, "G =:%5zd", p.getTies());
 }
 
-TTYSCRN* TTYSCRN::create(int acs, size_t y, size_t x)
+TTYSCRN* TTYSCRN::create(int acs, size_t *y, size_t *x)
 {
     int tx, ty;
 
@@ -201,11 +201,15 @@
     ty = getmaxy(stdscr);
 
     if (tx == ERR || ty == ERR
-       || static_cast<size_t>(tx) < x * 2 + TTYSCRN::offsx + 12
-       || static_cast<size_t>(ty) < y * 2 + TTYSCRN::offsy) {
+       || static_cast<size_t>(tx) < *x * 2 + TTYSCRN::offsx + 14
+       || static_cast<size_t>(ty) < *y * 2 + TTYSCRN::offsy) {
        endwin();
        return NULL;
     }
+    if (*x == 0)
+       *x = (tx - 14 - TTYSCRN::offsx) / 2;
+    if (*y == 0)
+       *y = (ty - TTYSCRN::offsy) / 2;
     cbreak();
     noecho();
 
diff -r b54e9703616d -r 9603ce68835a games/dab/ttyscrn.h
--- a/games/dab/ttyscrn.h       Sat Oct 06 19:23:01 2012 +0000
+++ b/games/dab/ttyscrn.h       Sat Oct 06 19:39:51 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttyscrn.h,v 1.3 2008/04/28 20:22:54 martin Exp $       */
+/*     $NetBSD: ttyscrn.h,v 1.4 2012/10/06 19:39:51 christos Exp $     */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 class TTYSCRN : public GAMESCREEN {
   public:
     // Constructor that can fail
-    static TTYSCRN*  create(int acs, size_t y, size_t x);
+    static TTYSCRN*  create(int acs, size_t *y, size_t *x);
     ~TTYSCRN();
 
     // Screen virtuals



Home | Main Index | Thread Index | Old Index