cvsuser     03/06/11 19:53:03

  Modified:    languages/BASIC/compiler COMP_expressions.pm
                        COMP_parsefuncs.pm COMP_parser.pm RT_builtins.pasm
                        RT_debugger.pasm compile.pl testsuite.pl
               languages/BASIC/compiler/samples chess.bas
  Log:
  Color chess now works.  :)  Debugger badly smashed.
  
  Revision  Changes    Path
  1.11      +14 -11    parrot/languages/BASIC/compiler/COMP_expressions.pm
  
  Index: COMP_expressions.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/COMP_expressions.pm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -r1.10 -r1.11
  --- COMP_expressions.pm       8 Jun 2003 17:25:25 -0000       1.10
  +++ COMP_expressions.pm       12 Jun 2003 02:52:59 -0000      1.11
  @@ -4,7 +4,7 @@
   use vars qw(@builtins @keywords);
   use strict;
   
  -my $retcount;
  +my $retcount=200;
   my $currentexpr;
   
   @builtins=qw(        abs             asc             atn
  @@ -508,22 +508,23 @@
                        next;
                }
                next if ($sym eq ",");  # Commas get ignored, args to stack
  -
  +             my($ac, @args, $extern);
                if (isarray($sym) and $lhs) {
  -                     my($ac,@args)=pushargs([EMAIL PROTECTED], \$optype, [EMAIL 
PROTECTED]);
  -                     my $extern=$sym;
  +                     ($ac,@args)=pushargs([EMAIL PROTECTED], \$optype, [EMAIL 
PROTECTED]);
  +                     $extern=$sym;
                        $optype=optype_of($extern);
  +                     goto NEST_ARRAY_ASSIGN if (@work); # Ugly, yeah sue me.
                        push @code, qq{\t.arg $ac\t\t\t# argc};
                        push @code, qq{\tINSERT NEW VALUE HERE};
                        push @code, qq{\t.arg "$extern$seg"\t\t# array name};
                        push @code, "\tcall _ARRAY_ASSIGN";
                        return("~Array", "$optype", @code);
                } elsif (hasargs($sym)) {
  -                     my($ac,@args)=pushargs([EMAIL PROTECTED], \$optype, [EMAIL 
PROTECTED]);
  -                     my $extern=$sym;
  +                     ($ac,@args)=pushargs([EMAIL PROTECTED], \$optype, [EMAIL 
PROTECTED]);
  +                     $extern=$sym;
                        $optype=optype_of($extern);
                        if (isarray($sym)) {
  -                             push @code, qq{\t.arg $ac\t\t\t# argc};
  +NEST_ARRAY_ASSIGN:           push @code, qq{\t.arg $ac\t\t\t# argc};
                                push @code, qq{\t.arg "$extern$seg"\t\t# array name};
                                push @code, "\tcall _ARRAY_LOOKUP_$optype";
                                if ($ac == 0) {
  @@ -596,11 +597,13 @@
   
        if ($left =~ /^\w+$/) {
                if ($left =~ /(_percent|_amp)$/) {
  +                     my $ti="\$I" . ++$retcount;
  +                     my $tn="\$N" . ++$retcount;
                        @ass=(
                                @$rightexpr,
  -                             "\tset \$I0, $right\t# Truncate",
  -                             "\tset \$N0, \$I0",
  -                             "\t$left = \$N0",
  +                             "\tset $ti, $right\t# Truncate",
  +                             "\tset $tn, $ti",
  +                             "\t$left = $tn",
                        );
                } else {
                        # Simple a=expr case.
  @@ -627,8 +630,8 @@
        %opts=%{$_[0]} if @_;
        my(@expr, @stream, @left, $whole);
        my($assignto, $result);
  -     $retcount=0;
        $whole="";
  +     $retcount=0;
        my $type="";
   
        if ($opts{assign}) {
  
  
  
  1.15      +22 -11    parrot/languages/BASIC/compiler/COMP_parsefuncs.pm
  
  Index: COMP_parsefuncs.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/COMP_parsefuncs.pm,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -w -r1.14 -r1.15
  --- COMP_parsefuncs.pm        8 Jun 2003 18:15:41 -0000       1.14
  +++ COMP_parsefuncs.pm        12 Jun 2003 02:52:59 -0000      1.15
  @@ -8,7 +8,7 @@
   use vars qw( $funcname $subname );
   use vars qw( %labels $branchseq @selects);
   use vars qw( @data $sourceline );
  -use vars qw( %code $debug );
  +use vars qw( %code $debug $runtime_jump);
   
   
   my @fors=();
  @@ -219,7 +219,7 @@
                push @{$code{$seg}->{code}}, "\tne $result, $i.0, ON_${ons}_$i\n";
                if ($branch eq "gosub") {
                        push @{$code{$seg}->{code}}, qq{\tbsr $labels{$jumps}\t# 
$branch $jumps\n};
  -                     push @{$code{$seg}->{code}}, qq{\tne S0, "", RUNTIME_JUMP\n};
  +                     push @{$code{$seg}->{code}}, qq{\t#RTJ ne S0, "", 
RUNTIME_JUMP\n};
                        push @{$code{$seg}->{code}}, qq{\tbranch ON_END_$ons\n};
                } elsif ($branch eq "goto") {
                        push @{$code{$seg}->{code}}, qq{\tbranch $labels{$jumps}\t# 
$branch $jumps\n};
  @@ -549,22 +549,25 @@
        push @{$code{$seg}->{code}}, "\tcall _RESTORE\n";
   }
   
  +
   sub parse_exit {
        if ($syms[NEXT] eq "for") {
                feedme();
                $foo=$fors[$scopes]->[-1];
  -             print CODE "\tbranch AFTER_NEXT_$foo->{jump}\n";
  +             push @{$code{$seg}->{code}}, "\tbranch AFTER_NEXT_$foo->{num}\n";
        } elsif ($syms[NEXT] eq "function") {
  +             push @{$code{$seg}->{code}}, qq{\tbranch END_$seg\n};
                feedme();
  -             $_=english_func($funcname);
  -             print CODE "\tbranch FUNC_EXIT_$_\n";
  +             #$_=english_func($funcname);
  +             #print CODE "\tbranch FUNC_EXIT_$_\n";
        } elsif ($syms[NEXT] eq "sub") {
  +             push @{$code{$seg}->{code}}, qq{\tbranch END_$seg\n};
                feedme();
  -             print CODE "\tbranch SUB_EXIT_$subname\n";
  +             #print CODE "\tbranch SUB_EXIT_$subname\n";
        } elsif ($syms[NEXT] eq "do") {
                feedme();
                $foo=$dos[-1];
  -             print CODE "\tbranch AFTERDO_$foo->{jump}\n";
  +             push @{$code{$seg}->{code}}, "\tbranch AFTERDO_$foo->{jump}\n";
        } else {
                die "Unknown EXIT type source line $sourceline";
        }
  @@ -803,7 +806,7 @@
   
        push @{$code{$seg}->{code}}, <<GOSUB;   
        bsr $labels{$syms[CURR]}\t# GOSUB $syms[CURR]
  -     ne JUMPLABEL, "", RUNTIME_JUMP
  +     #RTJ ne JUMPLABEL, "", RUNTIME_JUMP
   GOSUB
   }
   sub parse_return {
  @@ -818,6 +821,10 @@
        set JUMPLABEL, "$labels{$syms[CURR]}"  # Return $syms[CURR]
        ret
   RETURN2
  +             if (! $runtime_jump) {
  +                     warn "Note: RETURN x causes slow IMCC compilation\n";
  +                     $runtime_jump=1;
  +             }
        }
   }
   sub parse_loop {
  @@ -1249,6 +1256,7 @@
        $seg=~s/^_//;       # Remove the _
        $seg=~tr/A-Z/a-z/;  # lowercase
        $seg=~s/userfunc_//;
  +     push @{$code{$t}->{code}}, "END_$t:\n";
        if (exists $code{$t}->{args}) {
                foreach(@{$code{$t}->{args}}) {
                        push @{$code{$t}->{code}}, "\t.return $_\t# Returning arg\n";
  @@ -1346,9 +1354,12 @@
        # that are only discovered at runtime.
   RUNTIME_JUMP:
   RTB
  +     if ($runtime_jump) {
        foreach(sort keys %labels) {
                push @{$code{$seg}->{code}}, qq|\teq JUMPLABEL, "$labels{$_}", 
$labels{$_}\n|;
        }
  +     }
  +
        push @{$code{$seg}->{code}}, <<RTBE;
        print "Runtime branch of "
        print JUMPLABEL
  
  
  
  1.10      +2 -1      parrot/languages/BASIC/compiler/COMP_parser.pm
  
  Index: COMP_parser.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/COMP_parser.pm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -w -r1.9 -r1.10
  --- COMP_parser.pm    8 Jun 2003 03:46:23 -0000       1.9
  +++ COMP_parser.pm    12 Jun 2003 02:52:59 -0000      1.10
  @@ -8,7 +8,7 @@
   use constant NEXT => 0;
   use subs qw(dumpq EXPRESSION);
   use Data::Dumper;
  -use vars qw( %code $seg $debug );
  +use vars qw( %code $seg $debug $runtime_jump );
   
   require "COMP_parsefuncs.pm";
   
  @@ -77,6 +77,7 @@
        if (%opts) {
                print STDERR "Options: ", join(',', %opts), "\n";
        }
  +     $runtime_jump=0;
        init;
        runtime_init;
        feedme;
  
  
  
  1.5       +5 -1      parrot/languages/BASIC/compiler/RT_builtins.pasm
  
  Index: RT_builtins.pasm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/RT_builtins.pasm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- RT_builtins.pasm  6 Jun 2003 21:25:56 -0000       1.4
  +++ RT_builtins.pasm  12 Jun 2003 02:52:59 -0000      1.5
  @@ -107,6 +107,8 @@
        restoreall
        ret
   .end
  +# INT - a math function that returns the largest integer less than
  +#       or equal to a numeric-expression
   .sub _BUILTIN_INT            # float int(float arg)
        saveall
        .param int argc
  @@ -115,7 +117,9 @@
        .local int truncate
        set truncate, arg
        set res, truncate
  -     .return res
  +     ge arg, 0.0, ENDINT
  +     dec res
  +ENDINT:      .return res
        restoreall
        ret
   .end
  
  
  
  1.6       +2 -2      parrot/languages/BASIC/compiler/RT_debugger.pasm
  
  Index: RT_debugger.pasm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/RT_debugger.pasm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- RT_debugger.pasm  8 Jun 2003 14:30:24 -0000       1.5
  +++ RT_debugger.pasm  12 Jun 2003 02:52:59 -0000      1.6
  @@ -1,4 +1,4 @@
  -.sub _DEBUGGER_STOP  # void Debugger_stop(int line, PerlHash local_values)
  +.sub _DEBUGGER_STOP_FOR_REAL # void Debugger_stop(int line, PerlHash local_values)
        saveall
        .param int line
        .param PerlHash locals
  
  
  
  1.8       +5 -2      parrot/languages/BASIC/compiler/compile.pl
  
  Index: compile.pl
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/compile.pl,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -r1.7 -r1.8
  --- compile.pl        8 Jun 2003 17:25:25 -0000       1.7
  +++ compile.pl        12 Jun 2003 02:52:59 -0000      1.8
  @@ -34,7 +34,7 @@
   
   use vars qw( @tokens @tokdsc);
   use vars qw( @syms @type );
  -use vars qw( %labels );
  +use vars qw( %labels $runtime_jump );
   
   
   tokenize();
  @@ -64,7 +64,10 @@
                }
        }
   
  -     print CODE @{$code{$seg}->{code}};
  +     foreach(@{$code{$seg}->{code}}) {
  +             s/#RTJ// if $runtime_jump;
  +             print CODE $_;
  +     }
        print CODE "\trestoreall\n\tret\n";
        if ($debug) {
                print CODE<<'EOD';
  
  
  
  1.9       +93 -1     parrot/languages/BASIC/compiler/testsuite.pl
  
  Index: testsuite.pl
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/testsuite.pl,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- testsuite.pl      8 Jun 2003 18:15:41 -0000       1.8
  +++ testsuite.pl      12 Jun 2003 02:52:59 -0000      1.9
  @@ -32,6 +32,99 @@
   }
   
   __DATA__
  +' Evil BASIC bug, expect 55
  +dim B(1), z(1)
  +Z(54,6)=54
  +B(54)=1
  +Z1= 54
  +Z(Z1,6)= 54
  +B(Z(Z1,6))= 55
  +print B(Z(Z1,6))
  +
  +
  +' Comparison operator tests
  +if 4<5 then print "Ok" else print "Wrong"
  +if 5<5 then print "Wrong" else print "Ok"
  +if 6<5 then print "Wrong" else print "OK"
  +if 4<=5 then print "Ok" else print "Wrong"
  +if 5<=5 then print "Ok" else print "Wrong"
  +if 6<=5 then print "Wrong" else print "OK"
  +if 4=5 then print "Wrong" else print "Ok"
  +if 5=4 then print "Wrong" else print "Ok"
  +if 5=5 then print "Ok" else print "Wrong"
  +if 5>4 then print "Ok" else print "Wrong"
  +if 5>5 then print "Wrong" else print "Ok"
  +if 4>5 then print "Wrong" else print "OK"
  +if 5>=4 then print "Ok" else print "Wrong"
  +if 5>=5 then print "Ok" else print "Wrong"
  +if 4>=5 then print "Wrong" else print "OK"
  +
  +' Exit for, count 1-3
  +for i=1 to 5
  +  if i=4 then exit for
  +  print i
  +next i
  +
  +' Branch test, all OK in sequence
  +PRINT "1 in module-level code"
  +GOSUB Sub1
  +PRINT "ERR this line in main routine should be skipped"
  +Label1:
  +   PRINT "5 back in module-level code"
  +   END
  +Sub1:
  +   PRINT "2 in subroutine one"
  +   GOSUB Sub2
  +   PRINT "ERR this line in subroutine one should be skipped"
  +Label2:
  +   PRINT "4 back in subroutine one"
  +   RETURN Label1
  +Sub2:
  +   PRINT "3 in subroutine two"
  +   RETURN Label2   'Cannot return from here to main
  +                   'program - only to SUB1.
  +' Exit tests
  +sub mysub(b,c)
  +     print "Print me"
  +     exit sub
  +     print "Don't print me"
  +end sub
  +function foo$
  +     foo$="Right one"
  +     exit function
  +     foo$="Wrong one"
  +end function
  +call mysub( 78, 80)
  +t$=foo$
  +print t$
  +t=0
  +do
  +     print "This is right"
  +     exit do
  +     print "This is wrong"
  +     t=t+1
  +loop until t>1
  +
  +' Mathmagic
  +dim m(1), ba(1)
  +fa=-1
  +m0=48100
  +m=48000
  +w=-19
  +t=3
  +m(t)=-100
  +ba(fa+1)=9
  +w=w+M(T)+INT(M(T) * BA(FA + 1) / (BA(FA + 1) + 1) * (M0 - M) * .0001)
  +print w
  +
  +' INT madness.  0, 0, 0, -1, -1, 3
  +print int(.8),
  +print int(.3),
  +print int(0),
  +print int(-.8),
  +print int(-.3),
  +print int(3.14)
  +
   ' Simple subs, Made it here
   sub mysub()
        print "Made it here"
  @@ -47,7 +140,6 @@
   call twice t
   print t
   
  -STOPPLEASE
   ' Passing arrays, twice, expect 12
   function aftwo(y())
        print y(4)
  
  
  
  1.3       +183 -42   parrot/languages/BASIC/compiler/samples/chess.bas
  
  Index: chess.bas
  ===================================================================
  RCS file: /cvs/public/parrot/languages/BASIC/compiler/samples/chess.bas,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- chess.bas 6 Jun 2003 21:25:59 -0000       1.2
  +++ chess.bas 12 Jun 2003 02:53:03 -0000      1.3
  @@ -1,8 +1,111 @@
  -10 PRINT "  ****************************"
  -20 PRINT "  ** PROGRAMME D'ECHECS CSS **"
  -30 PRINT "  ****************************"
  -40 PRINT "     par Dieter Steinwender"
  -50 PRINT
  +' Chessboard.bas
  +'  ###  /\  +  www WWW  +   /\ ###  p
  +'  |R| {K  [B] (Q) |X| [B] {K  |R|  I
  +'  === === === === === === === === ===
  +sub rook(l1$,l2$,l3$)
  +     l1$="###"
  +     l2$="|R|"
  +     l3$="==="
  +end sub
  +sub knight(l1$,l2$,l3$)
  +     l1$=" /\\"
  +     l2$="{K"
  +     l3$="==="
  +end sub
  +sub bishop(l1$,l2$,l3$)
  +     l1$=" + "
  +     l2$="[B]"
  +     l3$="==="
  +end sub
  +sub queen(l1$,l2$,l3$)
  +     l1$="www"
  +     l2$="(Q)"
  +     l3$="==="
  +end sub
  +sub king(l1$,l2$,l3$)
  +     l1$="WWW"
  +     l2$="|X|"
  +     l3$="==="
  +end sub
  +sub pawn(l1$,l2$,l3$)
  +     l1$=" p "
  +     l2$=" I "
  +     l3$="==="
  +end sub
  +sub blank(l1$,l2$,l3$)
  +     l1$="   "
  +     l2$="   "
  +     l3$="   "
  +end sub
  +sub piece(x,y,color)
  +     call queen(one$, two$, three$) 
  +     locate y*3+1, x*5+2
  +     print one$
  +     locate y*3+2, x*5+2
  +     print two$
  +     locate y*3+3, x*5+2
  +     print three$
  +end sub
  +sub drawsquare(x,y,squarecolor,piece$)
  +     if squarecolor=1 then background=4 else background=6
  +     p$=left$(piece$, 1)
  +     if p$="*" then foreground=15 else foreground=0
  +     p$=right$(piece$,1)
  +     if p$="." then call blank(one$, two$, three$)
  +     if p$="P" then call pawn(one$, two$, three$)
  +     if p$="T" then call rook(one$, two$, three$)
  +     if p$="F" then call bishop(one$, two$, three$)
  +     if p$="C" then call knight(one$, two$, three$)
  +     if p$="D" then call queen(one$, two$, three$)
  +     if p$="R" then call king(one$, two$, three$)
  +
  +     if y=0 then posx$=chr$(65+x) else posx$=" "
  +     if x=0 then posy$=str$(8-y) else posy$=" "
  +     locate y*3+1, x*5+1
  +     color foreground, background
  +     print " ";one$;
  +     color 11, background
  +     print posx$;
  +     color foreground, background
  +     locate y*3+2, x*5+1
  +     print " ";two$;" ";
  +     locate y*3+3, x*5+1
  +     color 11, background
  +     print posy$;
  +     color foreground, background
  +     print three$;" ";
  +end sub
  +sub drawboard()
  +     locate 0,0
  +     c=0
  +     piece$=".P"
  +     for i = 0 to 7
  +     for j = 0 to 7
  +             call drawsquare( i, j, c mod 2, piece$ )
  +             c=c+1
  +     next j
  +     c=c+1
  +     next i
  +end sub
  +sub clearscreen(normalfore, normalback)
  +     cls
  +     color normalfore, normalback
  +     for i=1 to 24
  +     locate i, 41
  +     print string$(38, " ");
  +     next i
  +     locate 23,42 
  +     print "LV = Change Levels, NG = New Game";
  +     locate 24,42 
  +     print "Col/row for moves.  e.g. A2A3";
  +end sub
  +5  normalback=0
  +   normalfore=14
  +10 REM "  ****************************"
  +20 REM "  ** PROGRAMME D'ECHECS CSS **"
  +30 REM "  ****************************"
  +40 REM "     par Dieter Steinwender"
  +50 REM
   60 DEFINT A-L, N-Z
   70 DIM B(119), S(10, 4)
   71 DIM M(10), A$(10), U(10), F$(10)
  @@ -11,7 +114,9 @@
   80 DIM O(15), OA(6), OE(6), L(6), Z(200, 6)
   90 DIM ZT(9, 8), BV(8), BL(2, 9), TL(2, 9)
   100 DIM T7(2), BA(2), KR(2), KL(2)
  -200 RESTORE
  +110 et = 0
  +200 call clearscreen(normalfore, normalback)
  +    RESTORE
   210 REM: initialisation
   270 FOR I = 0 TO 119
   280 B(I) = 100
  @@ -70,9 +175,20 @@
   940 G1(0) = 1
   950 T0 = 1
   1800 T = 0
  -2000 REM: coup du joueur
  -2020 PRINT "   VOTRE COUP"; : INPUT E$
  -2050 IF E$ <> "DE" THEN 2070
  +2000 REM Process player commands
  +     color normalfore, normalback
  +     Gosub 4000
  +     color normalfore, normalback
  +     for i=12 to 20
  +             locate i, 42
  +     print string$(29, " ");
  +     next i
  +2020 locate 12, 42
  +     color normalfore, normalback
  +     PRINT "   Your move"; : INPUT E$
  +     locate 11, 42
  +     print string$(25, " ");
  +2050 IF E$ <> "NG" THEN 2070
   2060 GOTO 200
   2070 IF E$ <> "FI" THEN 2090
   2080 GOTO 15000
  @@ -100,8 +216,9 @@
   2300 GOSUB 9600
   2310 PRINT "  OK"
   2320 GOTO 2000
  -2330 IF E$ <> "PR" THEN 3000
  -2340 PRINT "  PROFONDEUR D'ANALYSE="; T0;
  +2330 IF E$ <> "LV" THEN 3000
  +2340 locate 12, 42
  +     PRINT "  Depth (1=Fast)="; T0;
   2350 INPUT T0
   2360 T0 = ABS(T0)
   2370 GOTO 2000
  @@ -115,15 +232,20 @@
   3070 IF Z(Z1, 1) <> V1 THEN 3090
   3080 IF Z(Z1, 2) = N1 THEN 3120
   3090 NEXT Z1
  -3100 PRINT "  COUP ILLEGAL"
  +3100 Locate 11, 42
  +     color 4,15
  +     PRINT "Illegal Move!";
  +     color 0,15
   3110 GOTO 2000
   3120 IF Z(Z1, 4) = 0 THEN 3170
   3140 IF RIGHT$(E$, 1) = "C" THEN Z1 = Z1 + 1
   3150 IF RIGHT$(E$, 1) = "F" THEN Z1 = Z1 + 2
   3160 IF RIGHT$(E$, 1) = "T" THEN Z1 = Z1 + 3
  -3170 PRINT "  VOTRE COUP: ";
  +3170 locate 3,42
  +     PRINT "Your move was ";
   3180 GOSUB 6000                      ' Posting
   3190 GOSUB 9000                      ' Executing
  +     GOSUB 4000                      ' Show board again
   3200 GOSUB 7000                      ' Generating moves
   3210 IF MT = 0 THEN 3300
   3220 GOSUB 9600                      ' Reprise?  Take it back?
  @@ -132,24 +254,26 @@
   3500 REM: coup de l'ordinateur  ' Computer's move
   3520 GOSUB 8800                      ' Initilaize the move tree
   _STARTASM
  -     time I0
  -     print "Start time: "
  -     print I0
  -     print "\n"
  +     time $I0
  +     et=$I0
   _ENDASM
   3530 GOSUB 10000             ' Seek?
   _STARTASM
  -     time I0
  -     print "End time: "
  -     print I0
  -     print "\n"
  +     time $I0
  +     $N0=$I0
  +     et=$N0-et
   _ENDASM
   3540 IF Z2 = 0 THEN 3650
   3545 IF W = 1 THEN 3660              ' Stalemate
   3550 IF W = -32766 THEN 3630 ' Player wins?
   3560 Z1 = Z2
  -3570 PRINT "  MON COUP: ";
  +3570 color 10, normalback
  +     locate 5,42
  +     PRINT "My move is ";
   3580 GOSUB 6000                      ' Post computer's move
  +     color 3, normalback
  +     locate 6,42
  +     print "Time "; et; " secs";
   3590 GOSUB 9000                      ' Execute it.
   3595 IF W = -2 THEN 3660
   3600 IF W < 32765 THEN 3670
  @@ -158,33 +282,45 @@
   3630 PRINT "  DAMNED, VOUS AVEZ GAGNE!"
   3640 GOTO 3670
   3650 IF T0 = 0 THEN 3670
  -3660 PRINT "  PAT: PARTIE NULLE!"
  -3670 PRINT "  VALEUR="; W; "  POSITIONS ANALYSEES="; C1
  +3660 locate 6,42
  +     PRINT "  PAT: PARTIE NULLE!"
  +3670 locate 7,42
  +     PRINT "Positions Analyzed="; C1
   3680 GOTO 2000
  -4000 REM: affichage de la position
  -4020 PRINT
  +
  +
  +4000 REM Draw the board
  +     sqc=0
  +4020 REM
  +     call drawboard
   4030 FOR I = 9 TO 2 STEP -1
  -4040 PRINT "  "; I - 1; "  ";
  +4040 ' PRINT "  "; I - 1; "  ";
   4050 FOR J = 1 TO 8
   4060 A1 = B(I * 10 + J)
   4070 F1 = SGN(A1)
   4080 A1 = ABS(A1)
  -4090 PRINT F$(F1 + 1); A$(A1); "  ";
  +     piece$=F$(F1+1) + A$(A1)
  +     call drawsquare(j-1, 9-i, sqc mod 2, piece$)
  +     sqc=sqc+1
  +4090 ' PRINT F$(F1 + 1); A$(A1); "  ";
   4100 NEXT J
  -4110 PRINT : PRINT
  +     sqc=sqc+1
  +4110 'PRINT : PRINT
   4120 NEXT I
  -4140 PRINT "        ";
  -4150 FOR J = 1 TO 8
  -4160 PRINT CHR$(64 + J); "   ";
  -4170 NEXT J
  -4180 PRINT : PRINT
  -4190 PRINT "   BILAN MATERIEL= "; M(T)
  -4200 PRINT "   CASE E.P.     =  "; : GOSUB 6700
  -4210 PRINT "   STATUT ROQUE  = "; S(T, 1); S(T, 2); S(T, 3); S(T, 4)
  -4220 PRINT "   AU TOUR DE    = ";
  -4230 IF F = 1 THEN PRINT " BLANC": GOTO 4250
  -4240 PRINT " NOIR"
  +4140 'PRINT "        ";
  +     ' FOR J = 1 TO 8
  +     ' PRINT CHR$(64 + J); "   ";
  +     ' NEXT J
  +4180 ' PRINT : PRINT
  +4190 ' PRINT "   BILAN MATERIEL= "; M(T)
  +4200 ' PRINT "   CASE E.P.     =  "; : GOSUB 6700
  +4210 ' PRINT "   STATUT ROQUE  = "; S(T, 1); S(T, 2); S(T, 3); S(T, 4)
  +4220 ' PRINT "   AU TOUR DE    = ";
  +4230 ' IF F = 1 THEN PRINT " BLANC": GOTO 4250
  +4240 ' PRINT " NOIR"
   4250 RETURN
  +
  +
   5000 REM: entree de la position
   5020 T = 0
   5030 PRINT "   VIDER L'ECHIQUIER(O/N) "
  @@ -455,7 +591,10 @@
   10200 W(T + 2) = W(T)
   10220 Z1 = P(T)
   10230 IF T <> 0 THEN 10250
  -10240 GOSUB 6000
  +10240 locate 14,42
  +      color normalback, normalfore
  +      print "Examining ";
  +      GOSUB 6000
   10250 GOSUB 9000
   10260 C1 = C1 + 1
   10270 GOTO 10070
  @@ -463,7 +602,9 @@
   10300 W(T + 2) = -W(T + 3)
   10310 IF T > 0 THEN 10340
   10320 Z2 = P(T)
  -10330 PRINT "  NOUVEAU MEILLEUR COUP "; "- VALEUR="; W(2)
  +10330 locate 15,42
  +      color normalback, normalfore
  +      PRINT "  Better move "; "- value ="; W(2)
   10340 IF W(T + 2) >= -W(T + 1) THEN 10380
   10350 P(T) = P(T) + 1
   10360 IF P(T) < G1(T + 1) THEN 10220
  
  
  

Reply via email to