DECLARE SUB Disp ()
DECLARE FUNCTION Calc% ()
DECLARE FUNCTION Box% (x%, y%)
DECLARE FUNCTION Norm% (i%)
DECLARE FUNCTION Symbol$ (i%)
DEFINT A-Z
WIDTH 40
CONST Max = 8
CONST N = 16
DIM SHARED a(0 TO N, 0 TO N)
DIM SHARED b(0 TO N, 0 TO N)
DIM SHARED c(0 TO Max, 0 TO 1)
FOR k = 0 TO 1: FOR i = 0 TO Max: READ c(i, k): NEXT i, k
FOR i = 0 TO N: FOR j = 0 TO N: READ a(i, j): NEXT j, i
DO
Disp
IF INKEY$ = CHR$(27) THEN EXIT DO
LOOP WHILE Calc < 1
WIDTH 80
SYSTEM
DATA 0,0,0,1,0,0,0,0,0
DATA 0,0,1,1,0,0,0,0,0
' #
DATA 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0
DATA 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0
DATA 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0
DATA 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0
FUNCTION Box (x, y)
l1 = x - 1
c1 = y - 1
l2 = x + 1
c2 = y + 1
ret = -b(x, y)
FOR i = l1 TO l2
FOR j = c1 TO c2
ret = ret + b(Norm(i), Norm(j))
NEXT
NEXT
Box = c(ret, b(x, y))
END FUNCTION
FUNCTION Calc
FOR i = 0 TO N: FOR j = 0 TO N: b(i, j) = a(i, j): NEXT j, i
FOR i = 0 TO N
FOR j = 0 TO N
a(i, j) = Box(i, j)
NEXT
NEXT
Calc = -1
END FUNCTION
SUB Disp
FOR i = 0 TO N
LOCATE i + 1
FOR j = 0 TO N
LOCATE , j + 1
PRINT Symbol$(a(i, j));
NEXT
NEXT
END SUB
FUNCTION Norm (i)
IF i = N + 1 THEN
Norm = 0
ELSEIF i = -1 THEN
Norm = N
ELSE
Norm = i
END IF
END FUNCTION
FUNCTION Symbol$ (i)
SELECT CASE i
CASE 0: Symbol$ = "°"
CASE 1: Symbol$ = "²"
CASE ELSE: Symbol$ = " "
END SELECT
END FUNCTION