return;
}
+ if(gs->promoType == 3) { // handle Shogi promotions
+ piece = gs->board[mt->fromFile][mt->fromRank];
+ if(colorval(piece) == WHITE && mt->fromRank < gs->ranks - gs->ranks/3
+ && mt->toRank < gs->ranks - gs->ranks/3 ) return;
+ if(colorval(piece) == BLACK && mt->fromRank >= gs->ranks/3
+ && mt->toRank >= gs->ranks/3 ) return;
+ switch(piecetype(piece)) {
+ case PAWN:
+ case LANCE:
+ case HONORABLEHORSE:
+ case SILVER:
+ if(s[1] != '+' && s[1] != '^' && s[1] != 'G' && s[1] != 'g') return;
+ piece = GOLD; break;
+ case BISHOP:
+ if(s[1] != '+' && s[1] != '^' && s[1] != 'H' && s[1] != 'h') return;
+ piece = DRAGONHORSE; break;
+ case ROOK:
+ if(s[1] != '+' && s[1] != '^' && s[1] != 'D' && s[1] != 'd') return;
+ piece = DRAGONKING; break;
+ default: return; // others do not promote, so ignore
+ }
+ mt->piecePromotionTo = piece | colorval(gs->board[mt->fromFile][mt->fromRank]);
+ return;
+ }
+
if (piecetype(gs->board[mt->fromFile][mt->fromRank]) != PAWN) {
return;
}