|
|
@ -61,62 +61,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
(func $getBoardPtr (result i32)
|
|
|
|
(func $getBoardPtr (result i32)
|
|
|
|
global.get $currentBuffer
|
|
|
|
global.get $currentBuffer
|
|
|
|
i32.eqz
|
|
|
|
global.get $boardBufferLength
|
|
|
|
if (result i32)
|
|
|
|
i32.mul
|
|
|
|
global.get $buffer0ptr
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
global.get $buffer1ptr
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(func $swapBoards
|
|
|
|
(func $swapBoards
|
|
|
|
global.get $currentBuffer
|
|
|
|
global.get $currentBuffer
|
|
|
|
i32.eqz
|
|
|
|
i32.eqz
|
|
|
|
if (result i32)
|
|
|
|
|
|
|
|
i32.const 1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
i32.const 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
global.set $currentBuffer
|
|
|
|
global.set $currentBuffer
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(func $positionInRange (param $position i32) (param $min i32) (param $max i32) (result i32)
|
|
|
|
(func $positionOutOfRange (param $position i32) (param $max i32) (result i32)
|
|
|
|
local.get $position
|
|
|
|
local.get $position
|
|
|
|
local.get $min
|
|
|
|
|
|
|
|
i32.lt_s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if
|
|
|
|
|
|
|
|
i32.const 0
|
|
|
|
i32.const 0
|
|
|
|
return
|
|
|
|
i32.lt_s
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local.get $position
|
|
|
|
local.get $position
|
|
|
|
local.get $max
|
|
|
|
local.get $max
|
|
|
|
i32.ge_s
|
|
|
|
i32.ge_s
|
|
|
|
|
|
|
|
|
|
|
|
if
|
|
|
|
i32.or
|
|
|
|
i32.const 0
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i32.const 1
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(func $getIndexForPosition (param $row i32) (param $column i32) (result i32)
|
|
|
|
(func $getIndexForPosition (param $row i32) (param $column i32) (result i32)
|
|
|
|
|
|
|
|
(local $result i32)
|
|
|
|
local.get $row
|
|
|
|
local.get $row
|
|
|
|
i32.const 0
|
|
|
|
|
|
|
|
global.get $boardHeight
|
|
|
|
global.get $boardHeight
|
|
|
|
call $positionInRange
|
|
|
|
call $positionOutOfRange
|
|
|
|
|
|
|
|
|
|
|
|
local.get $column
|
|
|
|
local.get $column
|
|
|
|
i32.const 0
|
|
|
|
|
|
|
|
global.get $boardWidth
|
|
|
|
global.get $boardWidth
|
|
|
|
call $positionInRange
|
|
|
|
call $positionOutOfRange
|
|
|
|
|
|
|
|
|
|
|
|
i32.and
|
|
|
|
i32.and
|
|
|
|
i32.eqz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if
|
|
|
|
if
|
|
|
|
i32.const -1
|
|
|
|
i32.const -1
|
|
|
|
return
|
|
|
|
return
|
|
|
|