summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-21 16:11:41 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-21 16:11:41 +0800
commit737556248c371c1a1f4302df7da2b0f3121ba7f2 (patch)
tree6194c448ba87e1d99728405cf4ef1f939f48583c
parent853dedc529d17b8aaab3433040737ac5b60e9440 (diff)
downloadpttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar
pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.gz
pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.bz2
pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.lz
pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.xz
pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.zst
pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.zip
Refactoring screen.c and adding function GetCurrentLine().
Adding redoscr() and use it in gomoku to reduce refresh size. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2418 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/proto.h1
-rw-r--r--mbbsd/gomo.c5
-rw-r--r--mbbsd/screen.c47
3 files changed, 41 insertions, 12 deletions
diff --git a/include/proto.h b/include/proto.h
index a6d3140d..66cd63ea 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -487,6 +487,7 @@ void prints(const char *fmt, ...) GCC_CHECK_FORMAT(1,2);
void region_scroll_up(int top, int bottom);
void outc(unsigned char ch);
void redoscr(void);
+void redoln(void);
void clrtoline(int line);
void standout(void);
void standend(void);
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index a7a4fd8e..b1bef205 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -176,6 +176,7 @@ HO_undo(char ku[][BRDSIZ], Horder_t * mv)
n2 = (mv->y == 14) ? 0 : (mv->y == 0) ? 2 : 1;
loc = 2 * (n2 * 3 + n1);
prints("%.2s", str + loc);
+ redoln();
}
static void
@@ -364,7 +365,7 @@ gomoku(int fd)
if (scr_need_redraw){
move(13, 40);
outs(my->turn ? "輪到自己下了!" : "等待對方下子..");
- redoscr();
+ redoln();
scr_need_redraw = 0;
}
if (lastcount != tick - now) {
@@ -490,6 +491,7 @@ gomoku(int fd)
bell();
BGOTO(mv.x, mv.y);
outs(bw_chess[he - 1]);
+ redoln();
if (win) {
outmsg(win == 1 ? "對方贏了!" : "對方禁手");
@@ -518,6 +520,7 @@ gomoku(int fd)
HO_add(&mv);
BGOTO(mv.x, mv.y);
outs(bw_chess[me - 1]);
+ redoln();
win = chkmv(ku, &mv, me, me == BBLACK);
ku[(int)mv.x][(int)mv.y] = me;
mylasttick = tick;
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 0e3e2af0..3232b1af 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -39,6 +39,14 @@ getyx(int *y, int *x)
*x = cur_col;
}
+static inline
+screenline_t* GetCurrentLine(){
+ register int i = cur_ln + roll;
+ if(i >= scr_lns)
+ i -= scr_lns;
+ return &big_picture[i];
+}
+
static void
rel_move(int was_col, int was_ln, int new_col, int new_ln)
{
@@ -130,6 +138,30 @@ redoscr()
oflush();
}
+void redoln()
+{
+ screenline_t *slp = GetCurrentLine();
+ int len, mode;
+
+ len = slp->len;
+ rel_move(tc_col, tc_line, 0, cur_ln);
+ if (len)
+ {
+ if ((mode = slp->mode) & STANDOUT)
+ standoutput((char*)slp->data, 0, len, slp->sso, slp->eso);
+ else
+ output((char*)slp->data, len);
+
+ slp->mode = mode & ~(MODIFIED);
+
+ slp->oldlen = tc_col = len;
+ }
+ else
+ clrtoeol();
+ rel_move(tc_col, tc_line, cur_col, cur_ln);
+ oflush();
+}
+
void
refresh()
{
@@ -220,13 +252,10 @@ clear()
void
clrtoeol()
{
- register screenline_t *slp;
+ register screenline_t *slp = GetCurrentLine();
register int ln;
standing = NA;
- if ((ln = cur_ln + roll) >= scr_lns)
- ln -= scr_lns;
- slp = &big_picture[ln];
if (cur_col <= slp->sso)
slp->mode &= ~STANDOUT;
@@ -272,13 +301,9 @@ clrtobot()
void
outc(unsigned char c)
{
- register screenline_t *slp;
+ register screenline_t *slp = GetCurrentLine();
register int i;
- if ((i = cur_ln + roll) >= scr_lns)
- i -= scr_lns;
- slp = &big_picture[i];
-
if (c == '\n' || c == '\r') {
if (standing) {
slp->eso = MAX(slp->eso, cur_col);
@@ -440,7 +465,7 @@ standout()
if (!standing && strtstandoutlen) {
register screenline_t *slp;
- slp = &big_picture[((cur_ln + roll) % scr_lns)];
+ slp = GetCurrentLine();
standing = YEA;
slp->sso = slp->eso = cur_col;
slp->mode |= STANDOUT;
@@ -453,7 +478,7 @@ standend()
if (standing && strtstandoutlen) {
register screenline_t *slp;
- slp = &big_picture[((cur_ln + roll) % scr_lns)];
+ slp = GetCurrentLine();
standing = NA;
slp->eso = MAX(slp->eso, cur_col);
}