Bombs

ClrText
" ":Green "        Bombs"
" ":Orange "    By: B. Conijn"
{21,7}->Dim Mat A
7*21->F
For 1->D To 21
Locate D,6,"*"
Intg 21Ran#+1->X
Intg 7Ran#+1->Y
If Mat A[X,Y]<9
Then 9->Mat A[X,Y]
For X-1->A To X+1
For Y-1->B To Y+1
If A>0 And A<22 And B>0 And B<8
Then Mat A[A,B]->C
C<9=>C+1->Mat A[A,B]
IfEnd
Next
Next
Dsz F
Else Dsz D
IfEnd
Next
1->X:1->Y:0->Z
ClrText
While 1
Isz Z
Z=8=>0->Z
Mat A[X,Y]->A
If Z<4
Then If A<0
Then Locate X,Y,Abs (A+1)
Else If Frac A>0
Then Locate X,Y,"X"
Else Locate X,Y,"#"
IfEnd
IfEnd
Else Locate X,Y,"#"
IfEnd
Getkey->G
If G=31
Then Mat A[X,Y]->A
If Intg A=9
Then Locate X,Y,"*"
Do
Getkey->G
LpWhile G=0 Or G=31
Stop
IfEnd
If A>=(-)1
Then If A>=0
Then Dsz F
Goto A
Locate X,Y,A
(-)Intg A-1->Mat A[X,Y]
Lbl C
Do
Getkey->G
LpWhile G=0 Or G=31
Stop
Lbl A
(-)Intg A-1->Mat A[X,Y]
IfEnd
If A<=0
Then X-1->B:X+1->C:Y-1->D:Y+1->E:B=0=>1->B:C=22=>21->C:D=0=>1->D:E=8=>7->E
For B->V To C
For D->W To E
Mat A[V,W]->A
If A>=0
Then Locate V,W,Intg A
(-)Intg A-1->Mat A[V,W]
Dsz F
Goto B
Goto C
Lbl B
IfEnd
Next
Next
IfEnd
IfEnd
0->Z
IfEnd
If G=78
Then Mat A[X,Y]->A
If A>=0
Then A+.5->Mat A[X,Y]
0->Z
IfEnd
IfEnd
If G>0
Then Mat A[X,Y]->A
If A<0
Then Locate X,Y,Abs (Mat A[X,Y]+1)
Else If Frac A=0
Then Locate X,Y," "
Else Locate X,Y,"X"
IfEnd
IfEnd
G=38=>X-1->X:G=27=>X+1->X:G=37=>Y+1->Y:G=28=>Y-1->Y:X=0=>1->X:X=22=>21->X:Y=0=>1->Y:Y=8=>7->Y
IfEnd
WhileEnd