Fix direction bits.

This commit is contained in:
yukirij 2024-08-18 11:36:31 -07:00
parent 10aa79366a
commit 6b596cc766
3 changed files with 13 additions and 21 deletions

View File

@ -561,7 +561,7 @@ GAME.Const = {
new MATH.Vec2(-2, -1), new MATH.Vec2(-2, -1),
new MATH.Vec2(-1, 1), new MATH.Vec2(-1, 1),
new MATH.Vec2(1, 3), /*new MATH.Vec2(1, 3),
new MATH.Vec2(2, 3), new MATH.Vec2(2, 3),
new MATH.Vec2(3, 2), new MATH.Vec2(3, 2),
new MATH.Vec2(3, 1), new MATH.Vec2(3, 1),
@ -572,7 +572,7 @@ GAME.Const = {
new MATH.Vec2(-3, -2), new MATH.Vec2(-3, -2),
new MATH.Vec2(-3, -1), new MATH.Vec2(-3, -1),
new MATH.Vec2(-2, 1), new MATH.Vec2(-2, 1),
new MATH.Vec2(-1, 2), new MATH.Vec2(-1, 2),*/
], ],
MoveStatus: { MoveStatus: {
@ -632,10 +632,10 @@ GAME.Const = {
.add(8) .add(8)
.add(9) .add(9)
.add(11) .add(11)
.add(25) .add(13)
.add(26) .add(14)
.add(28) .add(16)
.add(29), .add(17),
/*new GAME.PieceMovement() /*new GAME.PieceMovement()
.add(12) .add(12)
.add(13) .add(13)
@ -752,8 +752,8 @@ GAME.Const = {
], ],
get_direction(direction_id) { get_direction(direction_id) {
let direction = GAME.Const.Direction[direction_id % 24].copy(); let direction = GAME.Const.Direction[direction_id % GAME.Const.Direction.length].copy();
direction.mul(Math.ceil((direction_id + 1) / 24)); direction.mul(Math.ceil((direction_id + 1) / GAME.Const.Direction.length));
return direction; return direction;
}, },
}; };

View File

@ -592,19 +592,11 @@ const INTERFACE = {
} }
hints(piece) { hints(piece) {
let descriptor = GAME.Const.Piece[piece.piece]; let movement = piece.moves();
let moves = piece.moves(); let moves = movement.direction;
//if(((piece.player ^ INTERFACE_DATA.player ^ INTERFACE_DATA.rotate) & 1) != 0) { moves = moves.rotate(); }
moves = moves.direction;
for(let mask = BITWISE.lsb(moves); moves > 0; mask = BITWISE.lsb(moves)) { for(let mask = BITWISE.lsb(moves); moves > 0; mask = BITWISE.lsb(moves)) {
let move = BITWISE.ffs(mask); let move = BITWISE.ffs(mask);
if(move >= 24) {
move -= 24;
} else if(move >= 12) {
move = Math.floor((move - 12) / 2) + 6;
}
let nmove = move % 12; let nmove = move % 12;
this.ctx.strokeStyle = (piece.player == GAME.Const.Player.Dawn)? INTERFACE.Color.Dawn : INTERFACE.Color.Dusk; this.ctx.strokeStyle = (piece.player == GAME.Const.Player.Dawn)? INTERFACE.Color.Dawn : INTERFACE.Color.Dusk;

View File

@ -133,15 +133,15 @@ const BITWISE = {
{ {
const r1 = 0x00003F; // first 6 bits const r1 = 0x00003F; // first 6 bits
const r2 = 0x000FC0; // second 6 bits const r2 = 0x000FC0; // second 6 bits
const r3 = 0xFFF000; // third 12 bits const r3 = 0x03F000; // third 6 bits
let v1 = (r1 & mask) << 3; let v1 = (r1 & mask) << 3;
let v2 = (r2 & mask) << 3; let v2 = (r2 & mask) << 3;
let v3 = (r3 & mask) << 6; let v3 = (r3 & mask) << 3;
v1 = (v1 & r1) | ((v1 & ~r1) >> 6); v1 = (v1 & r1) | ((v1 & ~r1) >> 6);
v2 = (v2 & r2) | ((v2 & ~r2) >> 6); v2 = (v2 & r2) | ((v2 & ~r2) >> 6);
v3 = (v3 & r3) | ((v3 & ~r3) >> 12); v3 = (v3 & r3) | ((v3 & ~r3) >> 6);
return v1 | v2 | v3; return v1 | v2 | v3;
}, },