Revision | 994 (tree) |
---|---|
Time | 2013-12-06 00:35:42 |
Author | barnsey123 |
v0.089 much reduced memory footprint (36411)
The Possible Moves section much reduced as now only inversing squares instead of printing a "compass" - this also reduces the graphics files
@@ -323,7 +323,7 @@ | ||
323 | 323 | ; sta tmp1+1 |
324 | 324 | ; ldx #0 |
325 | 325 | ;loop |
326 | -; lda _pausetime,x | |
326 | +; lda _someint,x ; where someint represents say $9AD0 (for the char Z) | |
327 | 327 | ; ldy #0 |
328 | 328 | ; sta (tmp1),y |
329 | 329 | ; jsr _Add40 |
@@ -105,7 +105,7 @@ | ||
105 | 105 | #define SAGA 0 |
106 | 106 | #define THOR 1 |
107 | 107 | #define ODIN 2 |
108 | -#define TROPHY 12 | |
108 | +#define TROPHY 10 | |
109 | 109 | #define FIRSTBLOOD 1 |
110 | 110 | #define BLOODEAGLE 2 |
111 | 111 | #define BERZERKER 3 |
@@ -179,6 +179,7 @@ | ||
179 | 179 | unsigned char cantakepiece(); // returns 0=no, 1 yes |
180 | 180 | unsigned char checkroute(); // sets counter to be number of pieces on a given route |
181 | 181 | void blinkcursor(); // blinks the cursor to attract attention |
182 | +void blinkcursorB(); // subroutine of blinkcursor() | |
182 | 183 | void calccantake(); // can take be made (how many) |
183 | 184 | void calchightarget(); // updates value of hightarget (the highest target so far) |
184 | 185 | //void calctakeweight(); // calculate the weight of "takeweight" |
@@ -221,7 +222,8 @@ | ||
221 | 222 | void inctarget(); // inc target[xns][xew] |
222 | 223 | void inverse(); // inverse the color in the square |
223 | 224 | void movecursor2(); // move cursor routine |
224 | -void movepiece(); // move a piece | |
225 | +void movepiece(); // move a piece | |
226 | +void movepieceB(); // subroutine of movepiece() | |
225 | 227 | void pacman2(); // update target positions around king (need to develop further) |
226 | 228 | void pacman2b(); // subroutine of pacman2 |
227 | 229 | void pacman3(); |
@@ -279,9 +281,11 @@ | ||
279 | 281 | void DrawPictureTiles(); // called from lots of places so gets own function |
280 | 282 | //void cleartarget(); // set all targets to 1 (before adding redflag point values |
281 | 283 | void SubMoveCursor2(); // subroutine of movecursor2() to save memory |
284 | +void SubMoveCursor2b(); // subroutine of movecursor2() to save memory | |
282 | 285 | void CheckerBoard(); // Checkerboard screen wipe |
283 | 286 | void subCheckerBoard(); // subroutine of checkerboard |
284 | 287 | void subCheckerBoard2(); // subroutine 2 of checkerboard |
288 | +void SheldonGambit(); // called from subpacmanx (block left or right?) | |
285 | 289 | /****************** GLOBAL VARIABLES *******************************/ |
286 | 290 | /* Populate array with tile types |
287 | 291 | Tile types: |
@@ -350,7 +354,7 @@ | ||
350 | 354 | //char xloop=0; // general purpose loop variable |
351 | 355 | unsigned char xns=0; // copy of ns (arrows or blanks, and subarrows) |
352 | 356 | unsigned char xew=0; // copy of ew (arrows or blanks, and subarrows) |
353 | -unsigned char arrow=1; // used in arrowsorblanks(and subarrows) | |
357 | +unsigned char arrow=1; // used in arrowsorblanks(and subarrows) | |
354 | 358 | unsigned char flag=0; |
355 | 359 | unsigned char cantake; // can I take? (for computer turn) |
356 | 360 | unsigned char route; |
@@ -454,7 +458,6 @@ | ||
454 | 458 | //playertype=0; // 1=attacker, 2=defender (set at zero as incremented within loop) |
455 | 459 | firstblood=1; |
456 | 460 | ClearTrophies(); // initialize trophy array |
457 | - //PrintTrophyScreen(); | |
458 | 461 | drawboard(); // draw the board |
459 | 462 | while (gamestyle==3){ |
460 | 463 | message="PLAYERS:1-2"; // number of players |
@@ -486,11 +489,10 @@ | ||
486 | 489 | cy=ns; // cursor y screen position |
487 | 490 | playertype++; // playertype inited as 0 so ++ will make it 1 at start of game |
488 | 491 | if ( playertype == 3 ) { |
489 | - playertype = 1; turncount++; // was defender, set to attacker player, inc turncount | |
492 | + playertype = ATTACKER; turncount++; // was defender, set to attacker player, inc turncount | |
490 | 493 | if ( turncount > turnlimit ) gamestyle = 9; // signify end of game |
491 | 494 | } |
492 | - //if (( gamestyle == 0 )||((gamestyle==1)&&(playertype==2))||((gamestyle==2)&&(playertype==1))) | |
493 | - if ( gamestyle != 9 ){ // if turns not exceeded | |
495 | + if ( gamestyle != 9 ){ // if turns not exceeded | |
494 | 496 | if (( gamestyle == 0 )||((gamestyle==1)&&(playertype==2))){ |
495 | 497 | playerturn(); // player input |
496 | 498 | }else{ |
@@ -506,7 +508,7 @@ | ||
506 | 508 | */ |
507 | 509 | message=" ATTACKER WINS!"; // default (game=-2) |
508 | 510 | // king escapes or all attackers killed |
509 | - if ( game == 0 ) message=" KING WINS"; | |
511 | + if ( game == 0 ) message=" KING WINS"; | |
510 | 512 | // computer can't move |
511 | 513 | if ( game == -1 ) message="STALEMATE - OR TURN LIMIT EXCEEDED"; |
512 | 514 | // Award RAIDO AND URUZ Trophies (RAIDO = win on last turn, URUZ >=5 turns remaining) |
@@ -578,10 +580,13 @@ | ||
578 | 580 | for (ctns=0;ctns<11;ctns++){ |
579 | 581 | for (ctew=0;ctew<11;ctew++){ |
580 | 582 | ns=ctns;ew=ctew; |
581 | - if (( fb == 4 )&&(( players[ctns][ctew] == DEFENDER )||(players[ctns][ctew] == KING))) printdestinations(); | |
582 | - if (((fb == 5)||(fb == 7))&&( players[ctns][ctew] == ATTACKER)) printdestinations(); | |
583 | + //if (( fb == 4 )&&(( players[ctns][ctew] == DEFENDER )||(players[ctns][ctew] == KING))) printdestinations(); | |
584 | + //if (((fb == 5)||(fb == 7))&&( players[ctns][ctew] == ATTACKER)) printdestinations(); | |
585 | + //if (( fb == 8)&&( players[ctns][ctew] == KING )) printdestinations(); | |
586 | + | |
587 | + if ((( fb == 4 )&&(( players[ctns][ctew] == DEFENDER )||(players[ctns][ctew] == KING))) || (((fb == 5)||(fb == 7))&&( players[ctns][ctew] == ATTACKER)) || (( fb == 8)&&( players[ctns][ctew] == KING ))) printdestinations(); | |
583 | 588 | if (( fb == 6)&&( computer[ctns][ctew] )) updatetarget(); |
584 | - if (( fb == 8)&&( players[ctns][ctew] == KING )) printdestinations(); | |
589 | + | |
585 | 590 | } |
586 | 591 | } |
587 | 592 | } |
@@ -597,9 +602,8 @@ | ||
597 | 602 | if (( cantake == 0 )&&( surrounded < 3 )&&( redflagX == NO )) canbetaken(); // if cannot take can I be taken? |
598 | 603 | if (compass[origorient] == 0) foundpiece=1; |
599 | 604 | // check NORTH and SOUTH |
600 | - //if ((foundpiece == 1)&&(redflag[origorient] == NO)){ // can't be taken so we've found a candidate | |
601 | - if (foundpiece == 1){ // can't be taken so we've found a candidate | |
602 | - if (a != targetns) {// target is not on same row as candidate | |
605 | + if ((foundpiece == 1)&&(a != targetns)){ // can't be taken so we've found a candidate && target is not on same row as candidate | |
606 | + //if (a != targetns) {// target is not on same row as candidate | |
603 | 607 | if ((targetns == kingns)&&((a < 2)||(a > 8))){ |
604 | 608 | startrow=a;destrow=a;startcol=0;destcol=10; |
605 | 609 | //see if by moving a piece we leave the way open for the king to escape |
@@ -610,12 +614,11 @@ | ||
610 | 614 | if (a == kingns){ // if candidate is on same row as king (don't move away if only one piece E/W) |
611 | 615 | if (((b > kingew)&&(kingpieces[EAST]==1)) || ((b < kingew)&&(kingpieces[WEST]==1))) setfoundpiece10(); |
612 | 616 | } |
613 | - } | |
617 | + //} | |
614 | 618 | } |
615 | 619 | // CHECK EAST AND WEST |
616 | - //if ((foundpiece == 1)&&(redflag[origorient] == NO)){ // can't be taken so we've found a candidate | |
617 | - if (foundpiece == 1){ // can't be taken so we've found a candidate | |
618 | - if ( b != targetew){// target is not on same column as candidate | |
620 | + if ((foundpiece == 1)&&( b != targetew)){ // can't be taken so we've found a candidate && target is not on same column as candidate | |
621 | + //if ( b != targetew){// target is not on same column as candidate | |
619 | 622 | if ((targetew == kingew)&&((b < 2)||(b > 8))){ |
620 | 623 | startrow=0;destrow=10;startcol=b;destcol=b; |
621 | 624 | checkroute(); // returns z |
@@ -624,7 +627,7 @@ | ||
624 | 627 | if (b == kingew){ // if candidate is on same col as king (don't move away if only one piece N/S) |
625 | 628 | if (((a < kingns)&&(kingpieces[NORTH]==1)) || ((a > kingns)&&(kingpieces[SOUTH]==1))) setfoundpiece10(); |
626 | 629 | } |
627 | - } | |
630 | + //} | |
628 | 631 | } |
629 | 632 | if (foundpiece == 1){ |
630 | 633 | if (origorient < EAST){ |
@@ -635,7 +638,6 @@ | ||
635 | 638 | } |
636 | 639 | } |
637 | 640 | if ((players[a][b] == DEFENDER)||(players[a][b] == KING)) foundpiece=9; |
638 | - //if ((players[a][b] == CASTLE)&&(a!=5)) foundpiece=9; | |
639 | 641 | } |
640 | 642 | } |
641 | 643 | /* |
@@ -770,7 +772,6 @@ | ||
770 | 772 | cy=ons; // piece y screen position |
771 | 773 | blinkcursor(); // draw cursor in foreground color at piece to move position cx,cy |
772 | 774 | fb=0; |
773 | - //drawcursor(); // blank cursor | |
774 | 775 | cx=targetew; // target x screen position |
775 | 776 | cy=targetns; // target y screen position |
776 | 777 | blinkcursor(); // draw cursor in foreground color at target position cx,cy |
@@ -781,20 +782,6 @@ | ||
781 | 782 | void subpacmanx(){ |
782 | 783 | setpoints(); // Set points to 10 |
783 | 784 | surroundpoints(); // add 10 * surrounded |
784 | - /* | |
785 | - if (kingpieces[orientation] == 0){ | |
786 | - incpoints(); | |
787 | - if ((orientation<EAST)&&((kingew<2)||(kingew>8))) pointsplusten(); | |
788 | - if ((orientation>SOUTH)&&((kingns<2)||(kingns>8))) pointsplusten(); | |
789 | - } | |
790 | - */ | |
791 | - // TRIGGERHIGH/TRIGGERLOW = Weight to be added depending on kings closeness to border | |
792 | - /* | |
793 | - if (( orientation == NORTH )&&(kingns <= TRIGGERLOW)) pointsplusten(); | |
794 | - if (( orientation == SOUTH )&&(kingns >= TRIGGERHIGH)) pointsplusten(); | |
795 | - if (( orientation == EAST ) &&(kingew >= TRIGGERHIGH)) pointsplusten(); | |
796 | - if (( orientation == WEST ) &&(kingew <= TRIGGERLOW)) pointsplusten(); | |
797 | - */ | |
798 | 785 | points+=brokenarrow[orientation]*10; |
799 | 786 | //message="NOT SET"; |
800 | 787 | /* |
@@ -816,11 +803,12 @@ | ||
816 | 803 | } |
817 | 804 | */ |
818 | 805 | // "The Sheldon Gambit" |
819 | - for (x=0;x<8;x+=2){ | |
820 | - a=sheldon[orientation][x]; | |
821 | - b=sheldon[orientation][x+1]; | |
822 | - if ( enemy[a][b] ) pointsplusten(); | |
823 | - } | |
806 | + //for (x=0;x<8;x+=2){ | |
807 | + x=0; SheldonGambit(); | |
808 | + x=2; SheldonGambit(); | |
809 | + x=4; SheldonGambit(); | |
810 | + x=6; SheldonGambit(); | |
811 | + //} | |
824 | 812 | // REDFLAG detection |
825 | 813 | if (( kingpieces[orientation] == 0 )&&(kingtargets[orientation])){ // if no pieces in orientation from KING but there ARE targets |
826 | 814 | if (((orientation < EAST)&&((kingew<2)||(kingew>8))) || ((orientation > SOUTH)&&((kingns<2)||(kingns>8)))) { // NORTH/SOUTH OR EAST/WEST |
@@ -832,7 +820,12 @@ | ||
832 | 820 | } |
833 | 821 | subpacmany(); // apply the points |
834 | 822 | } |
823 | +void SheldonGambit(){ //called from subpacmanx | |
824 | + a=sheldon[orientation][x]; | |
825 | + b=sheldon[orientation][x+1]; | |
826 | + if ( enemy[a][b] ) pointsplusten(); | |
835 | 827 | |
828 | +} | |
836 | 829 | void subpacmany(){ // apply the points generated in pacman2-6 |
837 | 830 | // SET UNCOUNTER |
838 | 831 | pacman5(); // ensure correct paclevels are set |
@@ -874,7 +867,6 @@ | ||
874 | 867 | // kingtargets[orientation]= count of targets from king to edge |
875 | 868 | // kingpieces[]= count of pieces from king in a given orientation |
876 | 869 | unsigned char test=0; |
877 | - //unsigned char testreturn=0; | |
878 | 870 | setcheckmode1(); c=checkroute(); // how many pieces on the route? |
879 | 871 | checkroutemode=6; d=checkroute();// can king get to a T-row 0-1 |
880 | 872 | if (( c == 0 ) && ( d )) { |
@@ -1002,6 +994,9 @@ | ||
1002 | 994 | // count of pieces across the "T" |
1003 | 995 | // PARTIAL LEVEL 1 "LEFT" |
1004 | 996 | //points=50; // for level 1 |
997 | + // *** IMPORTANT *** | |
998 | + // It may look like you can save a few bytes by removing "redundant" statements | |
999 | + // here, but you can't as these values are altered later in this routine | |
1005 | 1000 | a=0;b=kingew;startrow=0;destrow=0;startcol=0;destcol=kingew; // NORTH |
1006 | 1001 | if ( orientation ){ |
1007 | 1002 | a=10;b=kingew;startrow=10;destrow=10;startcol=0;destcol=kingew; // SOUTH |
@@ -1053,10 +1048,9 @@ | ||
1053 | 1048 | lower=1; |
1054 | 1049 | upper=9; |
1055 | 1050 | } |
1056 | - if ((( orientation == NORTH )||( orientation == WEST ))&&(paclevel2 > lower)) checkbrokenarrow(); | |
1057 | - if ((( orientation == SOUTH )||( orientation == EAST ))&&(paclevel2 < upper)) checkbrokenarrow(); | |
1058 | - //if ((paclevel1 > 0 )&&(paclevel1 < 10)) test++; | |
1059 | - //if ( test==2 ) checkbrokenarrow(); | |
1051 | + //if ((( orientation == NORTH )||( orientation == WEST ))&&(paclevel2 > lower)) checkbrokenarrow(); | |
1052 | + //if ((( orientation == SOUTH )||( orientation == EAST ))&&(paclevel2 < upper)) checkbrokenarrow(); | |
1053 | + if (((( orientation == NORTH )||( orientation == WEST ))&&(paclevel2 > lower)) || ((( orientation == SOUTH )||( orientation == EAST ))&&(paclevel2 < upper))) checkbrokenarrow(); | |
1060 | 1054 | } |
1061 | 1055 | void pacman4(){ |
1062 | 1056 | // Cross the "T", see if a FULL broken arrow condition could exist (LEVEL 2) |
@@ -1096,13 +1090,13 @@ | ||
1096 | 1090 | game=-2 Attacker wins. |
1097 | 1091 | */ |
1098 | 1092 | // ns and ew contains new board co-ords of last piece moved |
1099 | - if ((( players[ns][ew] == 3 ) && ( tiles[ns][ew] == 4 ))||( deadattackers > 23)) game=0; // king has escaped | |
1093 | + if ((( players[ns][ew] == KING ) && ( tiles[ns][ew] == 4 ))||( deadattackers > 23)) game=0; // king has escaped | |
1100 | 1094 | // check to see if king is surrounded by attackers (first find king) |
1101 | - if ( players[ns][ew] == 1 ){ // if attacker was last to move | |
1102 | - if ((ns )&&(players[ns-1][ew] == 3 )) surroundcount(); | |
1103 | - if ((ns < 10 )&&(players[ns+1][ew] == 3 )) surroundcount(); | |
1104 | - if ((ew < 10 )&&(players[ns][ew+1] == 3 )) surroundcount(); | |
1105 | - if ((ew )&&(players[ns][ew-1] == 3 )) surroundcount(); | |
1095 | + if ( players[ns][ew] == ATTACKER ){ // if attacker was last to move | |
1096 | + if ((ns )&&(players[ns-1][ew] == KING )) surroundcount(); | |
1097 | + if ((ns < 10 )&&(players[ns+1][ew] == KING )) surroundcount(); | |
1098 | + if ((ew < 10 )&&(players[ns][ew+1] == KING )) surroundcount(); | |
1099 | + if ((ew )&&(players[ns][ew-1] == KING )) surroundcount(); | |
1106 | 1100 | if ( surrounded == 4 ) game=-2; // king is surrounded on all sides by attackers or king squares |
1107 | 1101 | } |
1108 | 1102 | if ( gamestyle == 9 ) game=-1; // turnlimit exceeded: stalemate |
@@ -1127,34 +1121,37 @@ | ||
1127 | 1121 | canmovecursor=0; |
1128 | 1122 | piecetype=players[ons][oew]; // determines the piece type that is currently selected (used in mode 1) |
1129 | 1123 | if ((mkey == 8 )&&( ew )){ // west |
1130 | - cursormodezero(); | |
1124 | + //cursormodezero(); | |
1131 | 1125 | xptrew--; // decrement copyew |
1132 | 1126 | skipew-=2; |
1133 | - incmodeone(); | |
1127 | + SubMoveCursor2b(); | |
1128 | + //incmodeone(); | |
1134 | 1129 | } |
1135 | 1130 | if ((mkey == 9 )&&( ew < 10)) { // east |
1136 | - cursormodezero(); | |
1131 | + //cursormodezero(); | |
1137 | 1132 | xptrew++; |
1138 | 1133 | skipew+=2; |
1139 | - incmodeone(); | |
1134 | + SubMoveCursor2b(); | |
1135 | + | |
1136 | + //incmodeone(); | |
1140 | 1137 | } |
1141 | 1138 | if ((mkey == 10)&&( ns < 10)){ // south |
1142 | - cursormodezero(); | |
1139 | + //cursormodezero(); | |
1143 | 1140 | xptrns++; |
1144 | 1141 | skipns+=2; |
1145 | - incmodeone(); | |
1142 | + SubMoveCursor2b(); | |
1143 | + | |
1144 | + //incmodeone(); | |
1146 | 1145 | } |
1147 | 1146 | if ((mkey == 11)&&( ns )){ // north |
1148 | - cursormodezero(); | |
1147 | + //cursormodezero(); | |
1149 | 1148 | xptrns--; |
1150 | 1149 | skipns-=2; |
1151 | - incmodeone(); | |
1150 | + SubMoveCursor2b(); | |
1151 | + //incmodeone(); | |
1152 | 1152 | } |
1153 | 1153 | if (( cursormode ) && ( modeonevalid )){ // if not at edge of board |
1154 | - //if ( players[xptrns][xptrew] == 0 ) canmovecursor=1; // ok if square vacant | |
1155 | - if ( tiles[xptrns][xptrew] == 4 ) canmovecursor=0; // !ok if corner | |
1156 | - //if (( piecetype == 3 )&&( tiles[xptrns][xptrew] > 2 )) canmovecursor=1; // ok if KING and corner/central | |
1157 | - //if (( xptrns == ons )&&( xptrew == oew )) canmovecursor=1; // ok if back to self | |
1154 | + if ( tiles[xptrns][xptrew] == 4 ) canmovecursor=0; // !ok if corner | |
1158 | 1155 | if (( players[xptrns][xptrew] == 0 )||(( piecetype == KING )&&( tiles[xptrns][xptrew] > 2 ))||(( xptrns == ons )&&( xptrew == oew ))) canmovecursor=1; |
1159 | 1156 | |
1160 | 1157 | // need to check that for non-king pieces wether the central square is vacant and can be skipped |
@@ -1187,8 +1184,11 @@ | ||
1187 | 1184 | if ( mkey == 10 )b+=multiple; // down |
1188 | 1185 | if ( mkey == 11 )b-=multiple; // up |
1189 | 1186 | } |
1190 | - | |
1191 | -// kicks off functions that print appropriate arrows at all possible | |
1187 | +void SubMoveCursor2b(){ | |
1188 | + cursormodezero(); | |
1189 | + incmodeone(); | |
1190 | +} | |
1191 | +// kicks off functions that highlights squares at all possible | |
1192 | 1192 | // destinations and blanks them out afterwards |
1193 | 1193 | void printpossiblemoves(){ |
1194 | 1194 | char k; // key entered |
@@ -1238,18 +1238,20 @@ | ||
1238 | 1238 | row=xns; |
1239 | 1239 | col=xew; |
1240 | 1240 | if ( arrow == 1 ){ // don't draw the arrow or update any array if arrow=2 |
1241 | - if (fb == 1) drawarrow(); // draw arrow | |
1241 | + if (fb < 2) drawarrow(); // draw arrow (if fb = 0 or 1) | |
1242 | 1242 | if (fb == 4) subarrows2(); // enemy can get here, update enemy array (direction specific) |
1243 | 1243 | if (fb == 5) computer[xns][xew]++;// computer can get here, increment computer array and set default target value |
1244 | - if (fb == 0) drawarrow(); // if MODE is "blank an arrow" | |
1244 | + //if (fb == 0) drawarrow(); // if MODE is "blank an arrow" | |
1245 | 1245 | if (fb == 8) kingtracker[xns][xew]=1; // king can get here... |
1246 | 1246 | } |
1247 | 1247 | } |
1248 | 1248 | // have we reached the end of the board? |
1249 | - if (( orientation == NORTH ) && ( xns == 0 )) zeroarrow(); // check north | |
1250 | - if (( orientation == SOUTH ) && ( xns == 10 )) zeroarrow(); // check south | |
1251 | - if (( orientation == EAST ) && ( xew == 10 )) zeroarrow(); // check east | |
1252 | - if (( orientation == WEST ) && ( xew == 0 )) zeroarrow(); // check west | |
1249 | + //if (( orientation == NORTH ) && ( xns == 0 )) zeroarrow(); // check north | |
1250 | + //if (( orientation == SOUTH ) && ( xns == 10 )) zeroarrow(); // check south | |
1251 | + //if (( orientation == EAST ) && ( xew == 10 )) zeroarrow(); // check east | |
1252 | + //if (( orientation == WEST ) && ( xew == 0 )) zeroarrow(); // check west | |
1253 | + | |
1254 | + if ((( orientation == NORTH ) && ( xns == 0 )) || (( orientation == SOUTH ) && ( xns == 10 )) || (( orientation == EAST ) && ( xew == 10 )) || (( orientation == WEST ) && ( xew == 0 ))) zeroarrow(); | |
1253 | 1255 | } |
1254 | 1256 | if ((fb == 7)&&(xplayers > ATTACKER)){ // check to see if an attacker can be caught if he stays where he is |
1255 | 1257 | if ((players[takerow][takecol] == 0)&&(enemy[takerow][takecol] )) { |
@@ -1262,7 +1264,7 @@ | ||
1262 | 1264 | else{ // if heading east or west |
1263 | 1265 | b=xew; |
1264 | 1266 | if ( xns < 10 ) {a=xns+1;sidestep();} |
1265 | - if ( xns ) {a=xns-1;sidestep();} | |
1267 | + if ( xns ) {a=xns-1;sidestep();} | |
1266 | 1268 | } |
1267 | 1269 | } |
1268 | 1270 | } |
@@ -1397,19 +1399,18 @@ | ||
1397 | 1399 | |
1398 | 1400 | // blinks the cursor a number of times to attract attention |
1399 | 1401 | void blinkcursor() { |
1400 | - //inversex=cx; | |
1401 | - //inversey=cy; | |
1402 | - for (counter=0;counter<5;inccounter()){ // flash the cursor to draw attention to it | |
1403 | - fb=0; | |
1404 | - //drawcursor(); // draw cursor in background color at cx,cy | |
1402 | + //for (counter=0;counter<5;inccounter()){ // flash the cursor to draw attention to it | |
1403 | + blinkcursorB(); blinkcursorB(); blinkcursorB(); blinkcursorB(); blinkcursorB(); | |
1404 | + //} | |
1405 | + if ((cx==5)&&(cy==5)) inverse(); | |
1406 | +} | |
1407 | +void blinkcursorB(){ | |
1408 | + fb=0; | |
1405 | 1409 | inverse(); |
1406 | 1410 | pausetime=500;pause(); |
1407 | 1411 | inverse(); |
1408 | 1412 | fb=1; |
1409 | - //drawcursor(); // draw cursor in foreground color at cx,cy | |
1410 | - pausetime=1000;pause(); | |
1411 | - } | |
1412 | - if ((cx==5)&&(cy==5)) inverse(); | |
1413 | + pausetime=1000;pause(); | |
1413 | 1414 | } |
1414 | 1415 | // flashes the screen in the selected ink color |
1415 | 1416 | void flashscreen() { |
@@ -1458,14 +1459,13 @@ | ||
1458 | 1459 | /*******************************************************/ |
1459 | 1460 | if (( xkey == 88) || ( xkey == 80)){ // if 'X' or 'P' is selected (88=X, 80=P) |
1460 | 1461 | canselect=0; // set piece to NOT SELECTABLE |
1461 | - if ((( playertype == ATTACKER )&&(players[ns][ew] == ATTACKER ))||(( playertype == DEFENDER )&&((players[ns][ew] == DEFENDER )||(players[ns][ew] == KING)))) canselect=1; // piece is selectable | |
1462 | - //if (( playertype == 2 )&&((players[ns][ew] == 2 )||(players[ns][ew] == 3))) canselect=1;// piece is selectable | |
1463 | - if ( canselect ){ | |
1462 | + if ((( playertype == ATTACKER )&&(players[ns][ew] == ATTACKER ))||(( playertype == DEFENDER )&&((players[ns][ew] == DEFENDER )||(players[ns][ew] == KING)))) { // piece is selectable | |
1463 | + canselect=1; // set piece is selectable | |
1464 | 1464 | canpiecemove(); |
1465 | 1465 | if (route ) { |
1466 | - flashcolor=GREEN;flashscreen(); // flash 2=green, 3=yellow | |
1467 | - if ( xkey == 80 ){ // if P is pressed | |
1468 | - printpossiblemoves(); // Print possible moves | |
1466 | + flashcolor=GREEN;flashscreen(); | |
1467 | + if ( xkey == 80 ){ // if P is pressed | |
1468 | + printpossiblemoves(); // Print possible moves | |
1469 | 1469 | printturnprompt(); |
1470 | 1470 | printturnline(); |
1471 | 1471 | } |
@@ -1499,14 +1499,7 @@ | ||
1499 | 1499 | if ( ons == ns ) cursormovetype=1; |
1500 | 1500 | if ( oew == ew ) cursormovetype=2; |
1501 | 1501 | } |
1502 | - //if (( ons == ns )&&( cursormovetype < 0)) cursormovetype=1; // cursor allowed north-south | |
1503 | - //if (( oew == ew )&&( cursormovetype < 0)) cursormovetype=2; // cursor allowed east-west | |
1504 | - if (( ons == ns )&& (oew == ew )) cursormovetype=0; // cursor can move | |
1505 | - | |
1506 | - //if (( cursormovetype == 2) && (( mkey == 8) ||(mkey == 9))) cursormovetype=-1; //!move | |
1507 | - //if (( cursormovetype == 1) && (( mkey == 10)||(mkey == 11)))cursormovetype=-1; //!move | |
1508 | - //if (( cursormovetype == 0) && (( mkey == 8) ||(mkey == 9))) cursormovetype=1; //move | |
1509 | - //if (( cursormovetype == 0) && (( mkey == 10)||(mkey == 11)))cursormovetype=2; //move | |
1502 | + if (( ons == ns )&& (oew == ew )) cursormovetype=0; // cursor can move | |
1510 | 1503 | if (( mkey >= 8 ) && ( mkey <= 11)){ |
1511 | 1504 | if ( cursormovetype > 0 ){ |
1512 | 1505 | if ((( cursormovetype == 2 )&&( mkey < 10 ))||((cursormovetype == 1)&&(mkey>9))) cursormovetype=-1; |
@@ -1525,34 +1518,23 @@ | ||
1525 | 1518 | } |
1526 | 1519 | if ( mkey == 82 ){ // R has been selected, Reset cursor to original positions |
1527 | 1520 | fb=0; |
1528 | - //drawcursor(); // blank out cursor at current position | |
1529 | - //inversex=cx; | |
1530 | - //inversey=cy; | |
1531 | 1521 | inverse(); |
1532 | - cx=ocx; // reset coords and board values to original positions | |
1522 | + cx=ocx; // reset coords and board values to original positions | |
1533 | 1523 | cy=ocy; |
1534 | 1524 | ns=ons; |
1535 | 1525 | ew=oew; |
1536 | - //inversex=cx; | |
1537 | - //inversey=cy; | |
1538 | 1526 | fb=1; |
1539 | - //drawcursor(); // draw cursor at original selected position | |
1540 | - inverse2(); | |
1541 | - inverse(); // inverse square | |
1527 | + inverse2(); inverse(); | |
1542 | 1528 | } |
1543 | 1529 | if ( mkey == 88 ){ // if X selected |
1544 | - //inversex=ocx; | |
1545 | - //inversey=ocy; | |
1546 | 1530 | inverse(); // inverse original position |
1547 | 1531 | // X is in original position so return to cursor movement |
1548 | - | |
1549 | 1532 | if (( ons == ns )&&( oew == ew)){ |
1550 | - inverse2(); | |
1551 | - inverse(); | |
1533 | + inverse2(); inverse(); | |
1552 | 1534 | mkey=0; // piece de-selected |
1553 | 1535 | } |
1554 | 1536 | else{ |
1555 | - movepiece(); // move selected piece | |
1537 | + movepiece();// move selected piece | |
1556 | 1538 | turn=0; // player has ended turn |
1557 | 1539 | } |
1558 | 1540 |
@@ -1594,7 +1576,7 @@ | ||
1594 | 1576 | } |
1595 | 1577 | } |
1596 | 1578 | // having moved piece we now need to check for, and implement any TAKES |
1597 | - if (piecetype > ATTACKER ){ // if defender | |
1579 | + if (piecetype > ATTACKER ){ // if defender/king | |
1598 | 1580 | p1=DEFENDER; |
1599 | 1581 | p2=KING; |
1600 | 1582 | } |
@@ -1601,21 +1583,21 @@ | ||
1601 | 1583 | tpew=ew; |
1602 | 1584 | takecounter=0; // set the take counter to zero (incremented in takepiece) |
1603 | 1585 | if ( ns > 1 ){// check north |
1604 | - orientation=NORTH; | |
1605 | - if ( cantakepiece() ) { tpns=ns-1; takepiece(); } | |
1586 | + orientation=NORTH; tpns=ns-1; movepieceB(); | |
1587 | + //if ( cantakepiece() ) { tpns=ns-1; takepiece(); } | |
1606 | 1588 | } |
1607 | 1589 | if ( ns < 9 ){ // check south |
1608 | - orientation=SOUTH; | |
1609 | - if ( cantakepiece() ) { tpns=ns+1; takepiece(); } | |
1590 | + orientation=SOUTH; tpns=ns+1; movepieceB(); | |
1591 | + //if ( cantakepiece() ) { tpns=ns+1; takepiece(); } | |
1610 | 1592 | } |
1611 | 1593 | tpns=ns; |
1612 | 1594 | if ( ew < 9 ){ // check east |
1613 | - orientation=EAST; | |
1614 | - if ( cantakepiece() ) { tpew=ew+1; takepiece(); } | |
1595 | + orientation=EAST; tpew=ew+1; movepieceB(); | |
1596 | + //if ( cantakepiece() ) { tpew=ew+1; takepiece(); } | |
1615 | 1597 | } |
1616 | 1598 | if ( ew > 1 ){ // check west |
1617 | - orientation=WEST; | |
1618 | - if ( cantakepiece() ) { tpew=ew-1; takepiece(); } | |
1599 | + orientation=WEST; tpew=ew-1; movepieceB(); | |
1600 | + //if ( cantakepiece() ) { tpew=ew-1; takepiece(); } | |
1619 | 1601 | } |
1620 | 1602 | |
1621 | 1603 | // update count of attackers around king |
@@ -1631,8 +1613,10 @@ | ||
1631 | 1613 | kingpieces[SOUTH]=0; |
1632 | 1614 | kingpieces[EAST]=0; |
1633 | 1615 | kingpieces[WEST]=0; |
1616 | + | |
1617 | + // perform NORTH/SOUTH checks | |
1618 | + cy=kingew; | |
1634 | 1619 | orientation=NORTH; |
1635 | - cy=kingew; | |
1636 | 1620 | for (counter=0;counter<kingns;inccounter()){ |
1637 | 1621 | cx=counter;incdefatt(); |
1638 | 1622 | } |
@@ -1640,18 +1624,24 @@ | ||
1640 | 1624 | for (counter=kingns+1;counter<11;inccounter()){ |
1641 | 1625 | cx=counter; incdefatt(); |
1642 | 1626 | } |
1627 | + // perform EASt/WEST check | |
1628 | + cx=kingns; | |
1643 | 1629 | orientation=EAST; // EAST |
1644 | - cx=kingns; | |
1645 | 1630 | for (counter=kingew+1;counter<11;inccounter()){ |
1646 | 1631 | cy=counter; incdefatt(); |
1647 | 1632 | } |
1633 | + | |
1648 | 1634 | orientation=WEST; // WEST |
1649 | 1635 | for (counter=0;counter<kingew;inccounter()){ |
1650 | 1636 | cy=counter; incdefatt(); |
1651 | 1637 | } |
1638 | + | |
1652 | 1639 | if (takecounter > 1) takemessage(); // display a firstblood/multiple takes message |
1653 | 1640 | } |
1654 | 1641 | |
1642 | +void movepieceB(){ | |
1643 | + if ( cantakepiece() ) takepiece(); | |
1644 | +} | |
1655 | 1645 | void incdefatt(){ |
1656 | 1646 | if (players[cx][cy] == ATTACKER) inckingattacker(); |
1657 | 1647 | if (players[cx][cy] == DEFENDER) inckingdefender(); |
@@ -1838,7 +1828,12 @@ | ||
1838 | 1828 | DrawPictureTiles(); |
1839 | 1829 | } |
1840 | 1830 | |
1841 | -void drawarrow(){ | |
1831 | +void drawarrow(){ // not really an arrow any more... | |
1832 | + a=cx;b=cy; // save contents of cx/cy to a/b | |
1833 | + cx=col;cy=row; // copy row/col to cx/cy for inverse function | |
1834 | + inverse(); // inverse the color at square cx/cy | |
1835 | + cx=a;cy=b; // restore contents of cx/cy from a/b | |
1836 | + /* | |
1842 | 1837 | if ( fb == 1 ){ |
1843 | 1838 | tiletodraw=10; |
1844 | 1839 | if ( tiles[row][col] ) tiletodraw++; // add another 1 for arrow with background |
@@ -1846,7 +1841,7 @@ | ||
1846 | 1841 | else{ |
1847 | 1842 | tiletodraw=tiles[row][col]; // draw original tile (includes blank) |
1848 | 1843 | } |
1849 | - DrawPictureTiles(); | |
1844 | + DrawPictureTiles();*/ | |
1850 | 1845 | } |
1851 | 1846 | |
1852 | 1847 | void surroundcount(){ |
@@ -1,6 +1,6 @@ | ||
1 | 1 | @ECHO OFF |
2 | 2 | |
3 | -%OSDK%\bin\pictconv -m0 -f0 -o4_PictureTiles pics\tiles.png pictiles.s | |
3 | +%OSDK%\bin\pictconv -m0 -f0 -o4_PictureTiles pics\tiles6.png pictiles.s | |
4 | 4 | %OSDK%\bin\pictconv -m0 -f0 -o4_ExplodeTiles pics\explode.png explode.s |
5 | 5 | %OSDK%\bin\pictconv -m0 -f0 -o4_BorderTiles2 pics\bordertiles2.png border.s |
6 | 6 | %OSDK%\bin\pictconv -m0 -f0 -o4_TitleTiles pics\defence-force2.png defence.s |
@@ -33,14 +33,8 @@ | ||
33 | 33 | .byt $5f,$42,$69,$7f,$72,$6b,$60,$7a,$63,$71,$78,$66,$71,$6c,$66,$40 |
34 | 34 | .byt $4c,$66,$40,$4c,$66,$40,$4c,$66,$71,$6c,$63,$71,$78,$6b,$60,$7a |
35 | 35 | .byt $69,$7f,$72,$68,$5f,$42,$6f,$40,$5e,$60,$40,$40,$7f,$7f,$7f,$60 |
36 | - .byt $40,$40,$60,$40,$40,$60,$40,$40,$60,$40,$40,$60,$44,$40,$60,$44 | |
37 | - .byt $40,$60,$4e,$40,$60,$55,$40,$61,$7f,$70,$60,$55,$40,$60,$4e,$40 | |
38 | - .byt $60,$44,$40,$60,$44,$40,$60,$40,$40,$60,$40,$40,$60,$40,$40,$60 | |
39 | - .byt $40,$40,$7f,$7f,$7f,$60,$40,$40,$6f,$40,$5e,$68,$40,$42,$68,$40 | |
40 | - .byt $42,$68,$44,$42,$60,$44,$40,$60,$4e,$40,$60,$55,$40,$61,$7f,$70 | |
41 | - .byt $60,$55,$40,$60,$4e,$40,$60,$44,$40,$68,$44,$42,$68,$40,$42,$68 | |
42 | - .byt $40,$42,$6f,$40,$5e,$60,$40,$40,$7f,$7f,$7f,$60,$40,$40,$63,$7f | |
43 | - .byt $78,$61,$7f,$70,$61,$71,$70,$61,$6a,$70,$61,$60,$70,$61,$6a,$70 | |
44 | - .byt $61,$71,$70,$60,$7f,$60,$60,$5f,$40,$60,$4e,$40,$60,$4e,$40,$60 | |
45 | - .byt $4e,$40,$60,$4e,$40,$60,$4e,$40,$60,$7f,$60,$60,$40,$40 | |
36 | + .byt $40,$40,$63,$7f,$78,$61,$7f,$70,$61,$71,$70,$61,$6a,$70,$61,$60 | |
37 | + .byt $70,$61,$6a,$70,$61,$71,$70,$60,$7f,$60,$60,$5f,$40,$60,$4e,$40 | |
38 | + .byt $60,$4e,$40,$60,$4e,$40,$60,$4e,$40,$60,$4e,$40,$60,$7f,$60,$60 | |
39 | + .byt $40,$40 | |
46 | 40 |