Revision | 1065 (tree) |
---|---|
Time | 2014-01-03 03:08:36 |
Author | barnsey123 |
v1.2 - new keyboard translation routine to translate A/Z and <> to their arrow key equivalents and SPACE/RETURN=X
@@ -91,6 +91,7 @@ | ||
91 | 91 | // 28-12-2013 NB v0.107 restored subcanbetaken2 and amended it... |
92 | 92 | // 30-12-2013 NB v1.000 1st v1 RELEASE! |
93 | 93 | // 31-12-2013 NB v1.1 Fixed bug in 2 player mode (instant stalemate) |
94 | +// 02-01-2014 NB v1.2 Alternate arrow keys (A,Z + <>) get translated to up/down/left/right | |
94 | 95 | /****************************************/ |
95 | 96 | // TODO: |
96 | 97 | // BUG somewhere in canbetaken |
@@ -326,6 +327,7 @@ | ||
326 | 327 | void Xenon4(); |
327 | 328 | //void Xenon5(); |
328 | 329 | void UpdateKingPieces(); // updates the count of pieces in each direction from king |
330 | +void TranslateKey(); // translates input so that alternative key selections can be made | |
329 | 331 | /****************** GLOBAL VARIABLES *******************************/ |
330 | 332 | /* Populate array with tile types |
331 | 333 | Tile types: |
@@ -443,7 +445,7 @@ | ||
443 | 445 | unsigned char p1; // piece type comparison (lower) - used for determining takes - default=attacker |
444 | 446 | unsigned char p2; // piece type comparison (upper) - used for determining takes - default=attacker |
445 | 447 | /* playerturn variables */ |
446 | -unsigned char xkey; // code of key pressed | |
448 | +//unsigned char xkey; // code of key pressed | |
447 | 449 | unsigned char canselect; // 0=no, 1=yes (is the piece selectable?) |
448 | 450 | char cursormovetype; // -1=no, 0=yes (n,s,e,w) 1=(north/south only), 2=(east/west only) |
449 | 451 | unsigned char turn; // determines end of player turn 1=playerturn, 0=end of playerturn |
@@ -1276,7 +1278,7 @@ | ||
1276 | 1278 | // kicks off functions that highlights squares at all possible |
1277 | 1279 | // destinations and blanks them out afterwards |
1278 | 1280 | void printpossiblemoves(){ |
1279 | - char k; // key entered | |
1281 | + //char k; // key entered | |
1280 | 1282 | fb=1; |
1281 | 1283 | printdestinations(); // print arrows on all destinations |
1282 | 1284 | //message="\n )() PRESS A KEY ()("; |
@@ -1284,7 +1286,8 @@ | ||
1284 | 1286 | //printmessage(); // "PRESS A KEY" |
1285 | 1287 | flashon(); // Make it FLASH RED |
1286 | 1288 | printturnline(); |
1287 | - k=getchar(); | |
1289 | + //k=getchar(); | |
1290 | + getchar(); | |
1288 | 1291 | //fb=0; |
1289 | 1292 | printdestinations(); // blank out arrows on all destinations |
1290 | 1293 | } |
@@ -1570,9 +1573,11 @@ | ||
1570 | 1573 | // print number of turns and remaining turns |
1571 | 1574 | printturnline(); |
1572 | 1575 | while (turn){ // repeat until move is made |
1573 | - xkey=getchar(); // get code of pressed key | |
1574 | - mkey=xkey; | |
1575 | - if (( xkey > 7 ) && ( xkey < 12 )){ // 8-11 = cursor keys | |
1576 | + //xkey=getchar(); // get code of pressed key | |
1577 | + //mkey=xkey; | |
1578 | + mkey=getchar(); | |
1579 | + TranslateKey(); | |
1580 | + if (( mkey > 7 ) && ( mkey < 12 )){ // 8-11 = cursor keys | |
1576 | 1581 | cursormode=0; // freeform |
1577 | 1582 | movecursor2(); |
1578 | 1583 | } |
@@ -1579,7 +1584,7 @@ | ||
1579 | 1584 | /*******************************************************/ |
1580 | 1585 | /* determine if X or P is selected (to select a piece) */ |
1581 | 1586 | /*******************************************************/ |
1582 | - if (( xkey == 88) || ( xkey == 80)){ // if 'X' or 'P' is selected (88=X, 80=P) | |
1587 | + if (( mkey == 88) || ( mkey == 80)){ // if 'X' or 'P' is selected (88=X, 80=P) | |
1583 | 1588 | canselect=0; // set piece to NOT SELECTABLE |
1584 | 1589 | if ((( playertype == ATTACKER )&&(players[ns][ew] == ATTACKER ))||(( playertype == DEFENDER )&&((players[ns][ew] == DEFENDER )||(players[ns][ew] == KING)))) { // piece is selectable |
1585 | 1590 | canselect=1; // set piece is selectable |
@@ -1586,7 +1591,7 @@ | ||
1586 | 1591 | canpiecemove(); |
1587 | 1592 | if (route ) { |
1588 | 1593 | flashcolor=GREEN;flashscreen(); |
1589 | - if ( xkey == 80 ){ // if P is pressed | |
1594 | + if ( mkey == 80 ){ // if P is pressed | |
1590 | 1595 | printpossiblemoves(); // Print possible moves |
1591 | 1596 | printturnprompt(); |
1592 | 1597 | printturnline(); |
@@ -1637,6 +1642,7 @@ | ||
1637 | 1642 | } |
1638 | 1643 | if ( cursormovetype < 0) { flashred();} // flashscreen red |
1639 | 1644 | mkey=getchar(); |
1645 | + TranslateKey(); | |
1640 | 1646 | } |
1641 | 1647 | if ( mkey == 82 ){ // R has been selected, Reset cursor to original positions |
1642 | 1648 | fb=0; |
@@ -2514,6 +2520,17 @@ | ||
2514 | 2520 | if ( x < 5 ) y=RED; |
2515 | 2521 | colorturn(); // set color for turn row |
2516 | 2522 | } |
2523 | +void TranslateKey(){ | |
2524 | + switch(mkey){ | |
2525 | + case 65: mkey=11; break; // A (up) | |
2526 | + case 90: mkey=10; break;// Z (down) | |
2527 | + case 44: mkey=8; break;// , ( < left) | |
2528 | + case 46: mkey=9; break;// . ( > right) | |
2529 | + case 32: mkey=88; break;// SPACE (X) | |
2530 | + case 13: mkey=88; break;// RETURN (X) | |
2531 | + } | |
2532 | + //xkey=mkey; | |
2533 | +} | |
2517 | 2534 | /* |
2518 | 2535 | void prioritycalc(){ // calculates the priorities of moving a piece |
2519 | 2536 | for(a=0;a<11;a++){ |
@@ -1,12 +1,25 @@ | ||
1 | 1 | @ECHO OFF |
2 | 2 | |
3 | +:: Redundant stuff | |
4 | +::%OSDK%\bin\pictconv -m0 -f0 -o4_TitleTiles pics\defence-force2.png defence.s | |
5 | +::%OSDK%\bin\pictconv -m0 -f0 -o4_RunicTiles pics\runes.png runes.s | |
6 | +::%OSDK%\bin\pictconv -m0 -f0 -d1 -o4_Mask pics\MaskSmallOric2.png mask.s | |
7 | +::%OSDK%\bin\pictconv -m0 -f0 -d1 -o3_MaskC pics\MaskSmallOric2.png mask.c | |
8 | +::%OSDK%\bin\pictconv -m0 -f0 -d1 -o0 pics\MaskSmallOric2.png maskf0d1.tap | |
9 | +::%OSDK%\bin\pictconv -m0 -f0 -d1 -o0 pics\xmas-mask2.png xmas.tap | |
10 | +::%OSDK%\bin\PictConv -f1 -d0 -o2 ..\..\data\picture.png %OSDK%\tmp\picture.hir | |
11 | +::%OSDK%\bin\FilePack -p %OSDK%\tmp\picture.hir %OSDK%\tmp\picture.pak | |
12 | +::%OSDK%\bin\Bin2Txt -s1 -f2 %OSDK%\tmp\picture.pak picture.s _LabelPicture | |
13 | + | |
14 | +:: For Main Program | |
15 | + | |
16 | +:: Main player piece and board tiles | |
3 | 17 | %OSDK%\bin\pictconv -m0 -f0 -o4_PictureTiles pics\tiles6.png pictiles.s |
18 | +:: Explosion sequence of a taken tile | |
4 | 19 | %OSDK%\bin\pictconv -m0 -f0 -o4_ExplodeTiles pics\explode.png explode.s |
20 | +:: Border tiles for Trophy Screen | |
5 | 21 | %OSDK%\bin\pictconv -m0 -f0 -o4_BorderTiles2 pics\bordertiles2.png border.s |
6 | -%OSDK%\bin\pictconv -m0 -f0 -o4_TitleTiles pics\defence-force2.png defence.s | |
7 | -%OSDK%\bin\pictconv -m0 -f0 -o4_RunicTiles pics\runes.png runes.s | |
22 | +:: The central timer sequence pictures | |
8 | 23 | %OSDK%\bin\pictconv -m0 -f0 -o4_TimerTiles pics\timer5.png timer.s |
9 | -%OSDK%\bin\pictconv -m0 -f0 -d1 -o4_Mask pics\MaskSmallOric2.png mask.s | |
10 | -%OSDK%\bin\pictconv -m0 -f0 -d1 -o3_MaskC pics\MaskSmallOric2.png mask.c | |
11 | -%OSDK%\bin\pictconv -m0 -f0 -d1 -o0 pics\MaskSmallOric2.png maskf0d1.tap | |
24 | + | |
12 | 25 | pause |