• R/O
  • SSH
  • HTTPS

oricsdk: Commit


Commit MetaInfo

Revision1065 (tree)
Time2014-01-03 03:08:36
Authorbarnsey123

Log Message

v1.2 - new keyboard translation routine to translate A/Z and <> to their arrow key equivalents and SPACE/RETURN=X

Change Summary

Incremental Difference

--- users/barnsey123/HNEFATAFL/main.c (revision 1064)
+++ users/barnsey123/HNEFATAFL/main.c (revision 1065)
@@ -91,6 +91,7 @@
9191 // 28-12-2013 NB v0.107 restored subcanbetaken2 and amended it...
9292 // 30-12-2013 NB v1.000 1st v1 RELEASE!
9393 // 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
9495 /****************************************/
9596 // TODO:
9697 // BUG somewhere in canbetaken
@@ -326,6 +327,7 @@
326327 void Xenon4();
327328 //void Xenon5();
328329 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
329331 /****************** GLOBAL VARIABLES *******************************/
330332 /* Populate array with tile types
331333 Tile types:
@@ -443,7 +445,7 @@
443445 unsigned char p1; // piece type comparison (lower) - used for determining takes - default=attacker
444446 unsigned char p2; // piece type comparison (upper) - used for determining takes - default=attacker
445447 /* playerturn variables */
446-unsigned char xkey; // code of key pressed
448+//unsigned char xkey; // code of key pressed
447449 unsigned char canselect; // 0=no, 1=yes (is the piece selectable?)
448450 char cursormovetype; // -1=no, 0=yes (n,s,e,w) 1=(north/south only), 2=(east/west only)
449451 unsigned char turn; // determines end of player turn 1=playerturn, 0=end of playerturn
@@ -1276,7 +1278,7 @@
12761278 // kicks off functions that highlights squares at all possible
12771279 // destinations and blanks them out afterwards
12781280 void printpossiblemoves(){
1279- char k; // key entered
1281+ //char k; // key entered
12801282 fb=1;
12811283 printdestinations(); // print arrows on all destinations
12821284 //message="\n )() PRESS A KEY ()(";
@@ -1284,7 +1286,8 @@
12841286 //printmessage(); // "PRESS A KEY"
12851287 flashon(); // Make it FLASH RED
12861288 printturnline();
1287- k=getchar();
1289+ //k=getchar();
1290+ getchar();
12881291 //fb=0;
12891292 printdestinations(); // blank out arrows on all destinations
12901293 }
@@ -1570,9 +1573,11 @@
15701573 // print number of turns and remaining turns
15711574 printturnline();
15721575 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
15761581 cursormode=0; // freeform
15771582 movecursor2();
15781583 }
@@ -1579,7 +1584,7 @@
15791584 /*******************************************************/
15801585 /* determine if X or P is selected (to select a piece) */
15811586 /*******************************************************/
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)
15831588 canselect=0; // set piece to NOT SELECTABLE
15841589 if ((( playertype == ATTACKER )&&(players[ns][ew] == ATTACKER ))||(( playertype == DEFENDER )&&((players[ns][ew] == DEFENDER )||(players[ns][ew] == KING)))) { // piece is selectable
15851590 canselect=1; // set piece is selectable
@@ -1586,7 +1591,7 @@
15861591 canpiecemove();
15871592 if (route ) {
15881593 flashcolor=GREEN;flashscreen();
1589- if ( xkey == 80 ){ // if P is pressed
1594+ if ( mkey == 80 ){ // if P is pressed
15901595 printpossiblemoves(); // Print possible moves
15911596 printturnprompt();
15921597 printturnline();
@@ -1637,6 +1642,7 @@
16371642 }
16381643 if ( cursormovetype < 0) { flashred();} // flashscreen red
16391644 mkey=getchar();
1645+ TranslateKey();
16401646 }
16411647 if ( mkey == 82 ){ // R has been selected, Reset cursor to original positions
16421648 fb=0;
@@ -2514,6 +2520,17 @@
25142520 if ( x < 5 ) y=RED;
25152521 colorturn(); // set color for turn row
25162522 }
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+}
25172534 /*
25182535 void prioritycalc(){ // calculates the priorities of moving a piece
25192536 for(a=0;a<11;a++){
--- users/barnsey123/HNEFATAFL/osdk_makedata.bat (revision 1064)
+++ users/barnsey123/HNEFATAFL/osdk_makedata.bat (revision 1065)
@@ -1,12 +1,25 @@
11 @ECHO OFF
22
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
317 %OSDK%\bin\pictconv -m0 -f0 -o4_PictureTiles pics\tiles6.png pictiles.s
18+:: Explosion sequence of a taken tile
419 %OSDK%\bin\pictconv -m0 -f0 -o4_ExplodeTiles pics\explode.png explode.s
20+:: Border tiles for Trophy Screen
521 %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
823 %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+
1225 pause
Show on old repository browser