NOTE: The game is long, and some code might be wrong. The code in the explanation field is probably more correct than the rest of it. If you see something that is wrong, please tell me and I will fix it. I at one point attempted to add ! to X. Please be wary of dumb stuff like that. LordoftheBleak

Minesweeper is a game where you must find all the mines on a field. Each time you step on a space, a number appears telling you how many mines are next to that square. You can flag a space as a mine. The game ends when you either find all the mines and step on all the spaces without mines, or when you step on a mine and die.

This is my first minesweeper game I have worked on. The Expert difficulty requires a a grid of 30 * 16, and in order to fit it on the screen, I had to use 3 * 3 squares. Since I couldn't fit numbers in that, I used dice faces. One dot is a "1". Two dots a "2" and so on. Unstepped spaces are dark, and flagged ones are half dark. Whichever spot your cursor is on is covered by the cursor, so it's number appears larger at the bottom of the screen. The mines are randomly placed, and the first square is never a mine. It automatically clears out areas when you step on a space that has no mines next to it. This process is time consuming, and I am working on that. The time it takes to do that is subtracted from your overall time, though. This is broken into many subprograms so I could work on it easier, but it may take a while to put on here.

If you die, it will reveal the field to you. Flagged mines remain the same. Unflagged mines are crosses, and flagged empty spaces are hollow crosses. Everything else is erased.

I can't make a high score system that can't be cracked into and modified without sufficient time and effort, but I can make it confusing as heck.

## Gameplay Edit

Use the arrow keys to move around on the screen. Your cursor appears as a cross with the center missing. Press 2nd to step on a space, and ALPHA to toggle the flag on the block. The number of mines remaining is displayed on the lower left hand corner. Next to it is the block your cursor is on. It keeps track of the fastest times for each difficulty. It also tries to keep you from editing those scores. The game automatically ends when you win or die. Press CLEAR to end the game early. You can play three default dfficulties or create a custom field that won't give you a fastest time.

## Code Edit

The **N** is the Finance variable N. Go to Apps, then Finance, then Vars. I%, PV, PMT, and FV can all be found there. n is found by pressing 2nd, then 0 (Catalog), then log (N).I don't know if it actually runs faster than any other variable, but I think it does. If you somehow don't have Finance App on your calculator, then you can swap out the finance variables for real ones (A-Z and θ). It will run slower, though.

### prgmMINES Edit

This is the main program, and the one you run.

:ClrHome :prgmCLRGRAPH :Degree :prgmθMINEFCE :0→dim(L2 :{0,0,0}→LHMINE :LHMINE-(LHMINE-999)not(LHMINE→LHMINE :0→dim(L3 :prgmθMINESCR :{9,9,10→L1 :Lbl 0 :Output(1,3,"MINE SWEEPER :Output(2,1,"---------------- :Output(3,1,">1: PLAY ("+sub("CEMH",1+minL1={9,9,10})+2minL1={16,16,40})+3minL1={30,16,99})+") :Output(4,2,"2: DIFFICULTY :Output(5,2,"3: HIGH SCORES :Output(6,2,"4: RESET SCORES :Output(7,2,"5: EXIT :3→N:Repeat max(FV={105,21,92,93,94,82,83}) :getKey→FV :If FV=25 or FV=34 :Then :Output N,1," " :N+(FV=34 and N≠7)-(FV=25 and N≠3→N:Output(N,1,"> :End :End :ClrHome :If FV≠21 and FV≠105 :max({3,4,5,6,7}(FV={92,93,94,82,83→N:IfN=4 :Goto 2 :IfN=5 :Goto 3 :IfN=6 :Goto 4 :IfN=7 :Goto 5 :Text(57,0,"LOADING... :For(X,0,3L1(2)-1 :Line(0,-X,3L1(1)-1,-X :End :1→N:1→I% :L1(3→PV :(L1(1)*L1(2))-PV→PMT :0→FV :[[0→[A] :L1(2)+1,L1(1)+1→dim([A] :Fill(.1,[A] :1+dim([A]→dim([A] :For(X,1,L1(2)+1 :0→[A](X,1 :End :For(X,1,L1(1)+1 :0→[A](1,X :End :1→X :1→Y :For(A,1,L1(3 :Repeat 9.1≠[A](Y,X :randInt(2,L1(1)+1→X :randInt(2,L1(2)+1→Y :End :9.1→[A](Y,X :End :0→T :Pt-Off(N,-I%,2 :Pt-On(N,-I%,3 :Pt-Off(N,-I% :Text(57,0,PV," " //53 Spaces :checkTmr(1→n:While FV≠45 and (PMT or PV) and FV≠1 :getKey→FV :If (FV=24 andN≠1) or (FV=25 and I%≠1) or (FV=26 andN≠3L1(2)-2) or (FV=34 and I%≠3L1(1)-2 :prgmθMINEMVE :If FV=21 and (.1=fPart([A]((I%+5)/3,(N+5)/3 :Then :If PMT=L1(1)*L1(2)-L1(3 :prgmθMINESET :If not(iPart([A]((I%+5)/3,(N+5)/3 :prgmθMINECLR :End :If FV=31 and (fPart([A]((I%+5)/3,(N+5)/3 :prgmθMINEMRK :End :checkTmr(1)-n :Ans-(Ans-999)(Ans>999→n :Text(57,0,sub("GAME OVERYOU WIN ",1+9(FV≠1 and FV≠45 and not(PMT or PV)),9 :If PV or PMT :prgmθMINESHW :ClrDraw :If not(PV or PMT :RecallPic 1 :If FV=45 :RecallPic 2 :If FV=1 :RecallPic 3 :If FV≠45 :Then :Text(50,0,"TIME: :Text(57,0,n :End :getKey :Repeat Ans :getKey :End :ClrDraw :min(L1={9,9,10})+2min(L1={16,16,40})+3min(L1={30,16,99 :If not(Ans :Goto 0 :If n≥L3(Ans) or FV=1 or FV=45 :Goto 0 :n→L3(Ans :Output(1,2,"FASTEST TIME! :getKey :Repeat Ans :getKey :End :ClrHome :Goto 3 :Lbl 2 :Output(1,3,"DIFFICULTIES :Output(2,1,"---------------- :Output(3,1,"1: EASY :Output(4,2,"2: MEDIUM :Output(5,2,"3: HARD :Output(6,1,"4: CUSTOM :Output(7,1,"5: BACK :3→N:Repeat max(FV={21,105,92,93,94,82,83 :getKey→FV :If FV=25 or FV=34 :Then :Output(N,1," " :N+(FV=34 andN≠7)-(FV=25 andN≠3→N:Output(N,1,"> :End :End :ClrHome :If FV≠21 and FV≠105 :max({3,4,5,6,7}(FV={92,93,94,82,83→N:IfN=3 :{9,9,10→L1 :IfN=4 :{16,16,40→L1 :IfN=5 :{30,16,99→L1 :IfN=6 :prgmθMINECST :Goto 0 :Lbl 3 :Output(1,7,"EASY :Output(4,7,"MEDIUM :Output(7,7,"HARD :For(X,2,8,3 :If not(iPart(log(L3((X+1)/3)))) or 1=iPart(log(L3((X+1)/3 :Output(X,8,L3((X+!)/3 :If 2=iPart(log(L3((X+1)/3 :Output(X,7,L3((X+1)/3 :End :getKey :Repeat Ans=21 or Ans=105 :getKey :End :ClrHome :Goto 0 :Lbl 4 :Output(1,2,"RESET SCORES? :Output(2,1,"---------------- :Output(3,1,">CANCEL :Output(4,2,"RESET :3→N:Repeat FV=21 or FV=105 :getKey→FV :If FV=25 or FV=34 :Then :Output(N,1," " :N+(FV=34 andN=3)-(FV=25 andN=4→N:Output(N,1,"> :End :End :ClrHome :IfN=4 :{999,999,999→L3 :Goto 0 :Lbl 5 :Output(1,1,"MADE BY: :Output(3,7,"LORD :Output(4,8,"OF :Output(5,7,"THE :Output(6,6,"BLEAK :prgmθMINESCR :DelVar L1DelVar L2DelVar L3DelVar [A]DelVar Pic1DelVar Pic2DelVar Pic3 :getKey :0 :Repeat getKey or Ans≥200 :Ans+1 :End :ClrHome :Output(1,1,"

### prgmθMINECLR Edit

This is the subprogram that clears areas when you step on a block that has no mines around it.

:Text(57,0,"PLEASE WAIT... :checkTmr(1→N :N→U :I%→V :{N+.01I%→L2 :1→T :While dim(L2 :iPart(L1(dim(L1→N:E2fPart(L2(dim(L2→I% :If .2≠fPart([A]((I%+5)/3,(N+5)/3 :Then :prgmθMINESTP :prgmθMINEDRW :If not([A]((I%+5)/3,(N+5)/3 :Then :For(X,N-3,N+3,3 :For(Y,I%-3,I%+3,3 :If fPart([A]((Y+5)/3,(X+5)/3)) and not(sum(L2=X+.01Y :augment({X+.01Y},L2→L2 :End :End :End :End :-1+dim(L2→dim(L2 :End :PMT+1→PMT :U→N:V→I% :0→T :Pt-On(N,-I%,3 :Pt-Off(N,-I% :getKey :For(X,-62,-57 :Line(0,X,64,X,0 :End :Text(57,0,PV :n+(checkTmr(1)-N→n

### prgmθMINECST Edit

This program is the menu fo a custom field. Originally I had it within Mines, but it proved hard to work on when I had to scroll so far down to edit it.

:Output(1,1,">X: [ :Output(2,2,"Y: [ :Output(3,2,"Z: [ :Output(1,6,L1(1 :Output(2,6,L1(2 :Output(3,6,L1(3 :Output(1,7+(L1(1)>9),"] :Output(2,7+(L1(2)>9),"] :Output(3,7+(L1(3)>9)+(L1(3)>99),"] :1→N:0→I% :Repeat (FV=105 or FV=21) and (not(max(L1=0)) and (L1(1)*L1(2)>L1(3 :getKey→FV :If (FV=25 andN≠1) or (FV=34 andN≠3 :Then :Output(N,1," " :N+(FV=34)-(FV=25→N:Output(N,1,"> :End :If max(FV={92,93,94,82,83,84,72,73,74,102,23,45 :Then :If max(FV={92,93,94,82,83,84,72,73,74,102 :10L1(N)+max({0,1,2,3,4,5,6,7,8,9}(FV={102,92,93,94,82,83,84,72,73,74→L1(N:If FV=23 :iPart(L1(N)/10→L1(N:If FV=45 :0→L1(N:L1-(L1-{31,19,588})(L1>{31,19,588→L1 :Output(N,6,Ans(N:Output(N,7+Ans(N)>9)+(Ans(N)>99),"] " :End :End

### prgmθMINEDRW Edit

This program draws the dice number on the field.

:Pt-Off(N,-I%,2 :Pt-Off(N,-I% :[A]((I%+5)/3,(N+5)/3 :If .1=fPart(Ans) or .2=fPart(Ans :Then :Pt-On(N,-I%,2 :Pt-On(N,-I% :End :If .2=fPart(Ans :Then :Pt-Off(N-1,-I% :Pt-Off(N-1,-I%-1 :Pt-Off(N,-I%-1 :End :If iPart(Ans) and not(fPart(Ans :Then :iPart(Ans :If Ans=2 or Ans≥4 :Pt-On(N-1,-I%+1 :If Ans=8 :Pt-On(N,-I%+1 :If Ans≥3 :Pt-On(N+1,-I%+1 :If Ans≥6 :Pt-On(N-1,-I% :If fPart(Ans/2 :Pt-On(N,-I% :If Ans≥6 :Pt-On(N+1,-I% :If Ans≥3 :Pt-On(N-1,-I%-1 :If Ans=8 :Pt-On(N,-I%-1 :If Ans=2 or Ans≥4 :Pt-On(N+1,-I%-1 :End

### prgmθMINEFCE Edit

This is the program that draws and saves the different faces.

:ClrDraw :Circle(47,-31,31,{i :Circle(37,-25,7,{i :Circle(57,-25,7,{i :For(X,225,315,3 :Pt-On(47+20cos(X),-31+20sin(X :End :StorePic 1 :ClrDraw :Circle(47,-31,31,{i :Circle(37,-25,7,{i :Circle(57,-25,7,{i :For(X,45,135,3 :Pt-On(47+20cos(X),-62+20sin(X :End :StorePic 2 :ClrDraw :Circle(47,-31,31,{i :Line(32,-15,42,-25 :Line(32,-25,42,-15 :Line(52,-15,62,-25 :Line(52,-25,62,-15 :Circle(47,-45,8,{i :StorePic 3 :ClrDraw

### prgmθMINEGUI Edit

This is the program that displays the large number at the bottom of the screen.

:Pt-Off(14,-61,2 :Pt-Off(14,-59,2 :Pt-Off(16,-61,2 :Pt-Off(16,-59,2 :If FV=1 or .1=fPart([A]((I%+5)/3,(N+5)/3 :Return :If fPart([A]((I%+5)/3,(N+5)/3 :Then :Pt-On(13,-58 :Pt-On(15,-58 :Pt-On(17,-58 :Pt-On(15,-60 :Pt-On(17,-60 :Pt-On(17,-62 :Else :iPart([A]((I%+5)/3,(N+5)/3 :If Ans=2 or Ans≥4 :Pt-On(13,-58 :If Ans=8 :Pt-On(15,-58 :If Ans≥3 :Pt-On(17,-58 :If Ans≥6 :Pt-On(13,-60 :If fPart(Ans/2 :Pt-On(15,-60 :If Ans≥6 :Pt-On(17,-60 :If Ans≥3 :Pt-On(13,-62 :If Ans=8 :Pt-On(15,-62 :If Ans=2 or Ans≥4 :Pt-On(17,-62 :End

### prgmθMINEMRK Edit

This is the program that flags and unflags spaces.

:iPart([A]((I%+5)/3,(N+5)/3))+.1not(fPart([A]((I%+5)/3,(N+5)/3))-.1→[A]((I%+5)/3,(N+5)/3 :PV+(fPart(Ans)=.1)-(fPart(Ans)=.2)→PV :Text(57,0,PV," " :prgmθMINEGUI

### prgmθMINEMVE Edit

This is the program that moves the cursor.

:prgmθMINEDRW :N+3((FV=26)-(FV=24→N:I%+3((FV=34)-(FV=25→I% :Pt-Off(N,-I%,2 :Pt-On(N,-I%,3 :Pt-Off(N,-I% :prgmθMINEGUI

### prgmθMINESCR Edit

This is the program that handles the high scores.

:If not(dim(L3 :Then :iPart(LHMINE→L1 :fPart(LHMINE→L2 :Else :L3→L1 :End :"^{2}√(e^(log()(tan^{-1}(X.1^{-1}X√ :seq(expr(sub(Ans,9,1)+sub(Ans,10,1)+sub(Ans,8,1)+sub(Ans,12,1)+sub(Ans,6,1)+sub(Ans,4,1)+sub(Ans,2,1)+sub(Ans,7,1)+sub(Ans,3,1)+sub(Ans,2,1)+"L1("+sub(Ans,8,1)+")"+sub(Ans,11,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,1,1)),X,1,3 :If not(dim(L3 :Then :L1*(L2=Ans→L3 :L3-(L3-999)not(L3→L3 :Else :L3+Ans→LHMINE :End

### prgmθMINESET Edit

This is the program that makes sure your first step is safe.

:If 9.1≠[A]((I%+5)/3,(N+5)/3 :Return :2→X :2→Y :While 9.1=[A](Y,X :Y+(X=L1(1)+1→Y :X+1-(X-1)(X=L1(1)+1→X :End :9.1→[A](Y,X

### prgmθMINESHW Edit

This is the program that reveals the mines at the end of the game.

:getKey :PV→X :PMT→Y :N→PV :I%→PMT :1→N:1→I% :Repeat Ans=21 or Ans=105 or ((I%+5)/3)-1>L1(2 :Pt-Off(N,-I%,2 :Pt-Off(N,-I% :[A]((I%+5)/3,(N+5)/3 :If (9=iPart(Ans) and .2{!=}}fPart(Ans)) or (FV=1 andN=PV and I%=PMT :Pt-On(N,-I%,3 :If .2=fPart(Ans :Then :If 9=iPart(Ans :Then :Pt-On(N-1,-I%+1 :Pt-On(N,-I%+1 :Pt-On(N+1,-I%+1 :Pt-On(N,-I% :Pt-On(N-1,-I% :Pt-On(N-1,-I%-1 :Else :Pt-On(N,-I%,3 :Pt-Off(N,-I% :End :End :N+3→N:If ((N+5)/3)-1)L1(1 :Then :1→N:I%+3→I% :End :getKey :End :If not(Ans :Then :1→N:Repeat Ans :N+1-N(N≥40→N:If not(N:Pt-Off(PV,-PMT,2 :IfN=21 :Then :Pt-On(PV,-PMT,2 :Pt-Off(PV,-PMT,3 :End :IfN=0 orN=21 :Pt-On(PV,-PMT :getKey :End :End :X→PV :Y→PMT

### prgmθMINESTP Edit

This program clears a space you step on.

:If 9=iPart([A]((I%+5)/3,(N+5)/3 :1→FV :0 :For(X,-1+(N+5)/3,1+(N+5)/3 :For(Y,-1+(I%+5)/3,1+(I%+5)/3 :Ans+(9=iPart([A](Y,X :End :End :Ans→[A]((I%+5)/3,(N+5)/3 :PMT-1→PMT :If not(T :prgmθMINEGUI

## Explanation Edit

### Main Program Edit

:ClrHome :prgmCLRGRAPH :Degree

This section sets up the graph screen. It makes the pixels have exact integer X and Y coordinate with the Pt-On( and Pt-Off( commands. The smiles on the faces use cos( and sin( functions, and need to be in Degree mode to work properly as well.

```
:prgmθMINEFCE
```

This program saves the faces used in the game. The code for that will be explained elsewhere.

:SetUpEditor L2 :0→dim(L2 :SetUpEditor LHMINE :3→LHMINE

The SetUpEditor, when used, will make sure that the list you want exists and is in your RAM. L2 is a general purpose list, so it is left with a dimension of 0. LHMINE is the high scores. This makes certain that it has dimension of 3.

:LHMINE-(LHMINE-999)not(LHMINE→LHMINE :0→dim(L3

If LHMINE has any data entry with integer 0, it resets it to 999. This is only possible if the list is deleted, shortened, or manually edited. You cannot get a best time of 0. L3 is another high score list. It is used as the high scores while the game is running, and saves back as LHMINE when you exit the game.

```
:prgmθMINESCR
```

This program checks if you modified your highscores, and resets any modified score.

:{9,9,10→L1

L1 is the list that holds the properties of the field. It is {# Spaces Horizontal, # Spaces Vertical, # Mines.

:Lbl 0 :Output(1,3,"MINE SWEEPER :Output(2,1,"---------------- :Output(3,1,">1: PLAY ("+sub("CEMH",1+minL1={9,9,10})+2minL1={16,16,40})+3minL1={30,16,99})+") :Output(4,2,"2: DIFFICULTY :Output(5,2,"3: HIGH SCORES :Output(6,2,"4: RESET SCORES :Output(7,2,"5: EXIT :3→N

This displays the main menu and sets the cursor (**N**) to 3 (PLAY).

:Repeat max(FV={105,21,92,93,94,82,83

The code will repeat until FV (keypress) is 2nd, Enter, 1, 2, 3, 4, or 5.

:getKey→FV :If FV=25 or FV=34 :Then

If you press up or down...

:Output N,1," " :N+(FV=34 and N≠7)-(FV=25 and N≠3→N:Output(N,1,">

It erases your cursor, and moves the cursor provided that it isn't trying to move off of the menu. Then it redisplays it.

:End :End :ClrHome :If FV≠21 and FV≠105 :max({3,4,5,6,7}(FV={92,93,94,82,83→N

To simplify the code below, this checks if you pressed 2nd or Enter. If you didn't, your cursor could be on any option, probably not the option you selected. This code sets the cursor position to your keypress. If you pressed "1", it jumps to "3" (the first option, "PLAY", is on the 3rd row on the screen).

:IfN=4 :Goto 2 :IfN=5 :Goto 3 :IfN=6 :Goto 4 :IfN=7 :Goto 5

This jumps to the appropriate area of the program based on **N**'s value. It doesn't do anything if you chose "PLAY" because the game code is righ below this section.

:Text(57,0,"LOADING... :For(X,0,3L1(2)-1 :Line(0,-X,3L1(1)-1,-X :End

This tells you the game is setting up the field and draws the field.

:1→N:1→I% :L1(3→PV :(L1(1)*L1(2))-PV→PMT :0→FV

This area sets up the variables. **N** is the cursor's X position. I% its Y position. PV is how many mines there are. PMT is how many unstepped spaces there are.

:[[0→[A] :L1(2)+1,L1(1)+1→dim([A] :Fill(.1,[A] :1+dim([A]→dim([A] :For(X,1,L1(2)+1 :0→[A](X,1 :End :For(X,1,L1(1)+1 :0→[A](1,X :End

This code sets up [A], the field. Each data entry is 1 space. The integer is how many mines are around it. This value is "0" until you step on it. Then it gets filled in. It is set to "9", however, if the space is a mine (you can't have 9 mines around a block). The decimal part is the block's status. A decimal of "0" is stepped on. A decimal of ".1" is unstepped, and ".2" is flagged. [A] is set to have 2 extra rows and 2 extra columns that make the edges. The edges have a value of "0", and everything else is ".1". This is useful later during the game. Having the edges speeds up the game when you step on a space. I'll explain that in the prgmθMINESTP.

:1→X :1→Y :For(A,1,L1(3 :Repeat 9.1≠[A](Y,X :randInt(2,L1(1)+1→X :randInt(2,L1(2)+1→Y :End :9.1→[A](Y,X :End

This code places the mines. The For( loop is set to repeat as many times as you have mines. It then repeats within the For( loop until it randomly selects a space that has no mine. Then, it sets that place to have a mine and then the For( loop goes again.

:0→T :Pt-Off(N,-I%,2 :Pt-On(N,-I%,3 :Pt-Off(N,-I% :Text(57,0,PV," " //53 Spaces :checkTmr(1→n

T is the variable that says whether or not prgmθMINECLR is running. It's only use is to test whether or not to run prgmθMINEGUI from within prgmθMINECLR. The code then displays your cursor at the top left of the field and clears the "LOADING..." message and replaces it with PV (the number of mines). PV decreases whenever a space is flagged, regardless of whether or not the space actually has a mine. n stores the time you start the game.

:While FV≠45 and (PMT or PV) and FV≠1

The game will loop until FV=45 (you press clear), PMT=0 and PV=0 (there are no unstepped spacess and no unflagged mines), or FV=1 (you step on a mine).

:getKey→FV :If (FV=24 andN≠1) or (FV=25 and I%≠1) or (FV=26 andN≠3L1(2)-2) or (FV=34 and I%≠3L1(1)-2 :prgmθMINEMVE

This gets your keypress and checks if you are pressing one of the arrows. If you are, and your cursor isn't on the edge of the field you want to move towards, it runs prgmθMINEMVE.

:If FV=21 and (.1=fPart([A]((I%+5)/3,(N+5)/3 :Then

If you want to step on a space (press 2nd) and the space is unstepped and unflagged, it continues. The (I%+5)/3 and (**N**+5)/3 is the code that takes the cursor coordinate and matches it to the correct spot in [A].

```
:If PMT=L1(1)*{L1(2)-L1(3
:prgmθMINESET
```

If this is your first step, then it will run prgmθMINESET, which will move a mine if you stepped on it.

:prgmθMINESTP :If not(iPart([A]((I%+5)/3,(N+5)/3 :prgmθMINECLR :End

This code runs prgmθMINESTP, which steps on a space. If the space has no adjacent mines (an iPart( of 0), it runs prgmθMINECLR, which continues to clear spaces until no linked space has no adjacent mines.

:If FV=31 and (fPart([A]((I%+5)/3,(N+5)/3 :prgmθMINEMRK :End

If you pressed ALPHA and the space is unstepped it runs prgmθMINEMRK, which will toggle the flag.

:checkTmr(1)-n :Ans-(Ans-999)(Ans>999→n

This piece subtracts the starting time from the current time, so it results in the time you played the game. Then, if the time is over 999, it makes it equal to 999.

:Text(57,0,sub("GAME OVERYOU WIN ",1+9(FV≠1 and FV≠45 and not(PMT or PV)),9

If you quit or died, it displayes "GAME OVER". Otherwise, it displays "YOU WIN".

```
:If FV=1
:prgmθMINESHW
```

If you died, it show you the field (prgmθMINESHW). It also displays a little animation on the spot you died on.

:ClrDraw :If not(PV or PMT :RecallPic 1 :If FV=45 :RecallPic 2 :If FV=1 :RecallPic 3

Here it displays the appropriate face. Pic1 is when you win and is a smiley face. Pic2 is when you quit and is a sad face. Pic3 is when you die and is a dead face.

:If FV≠45 :Then :Text(50,0,"TIME: :Text(57,0,n :End :getKey :Repeat Ans :getKey :End

If you didn't quit, it displays the time you spent playing the game. It then pauses until you press a key.

:ClrDraw :min(L1={9,9,10})+2min(L1={16,16,40})+3min(L1={30,16,99 :If not(Ans :Goto 0

This checks if the field was a default difficulty. If it wasn't, it goes back to the main menu. {9,9,10}, {16,16,40}, and {30,16,99} are the dimensions for a default field. If you set a custom field to the same settings as a default, it still counts this way.

:If n≥L3(Ans) or FV=1 or FV=45 :Goto 0

If the field was a default setting, the previous code set Ans to either 1, 2, or 3 depending on the difficulty. If the time is greater than or equal to the fastest time for the same difficulty, if you died, or if you quit, it sends you to the main menu.

:n→L3(Ans :Output(1,2,"FASTEST TIME! :getKey :Repeat Ans :getKey :End :ClrHome :Goto 3

If this code is run, you had a fastest time. It tells you that, and pauses until you press a key. Then it goes to the high score screen.

:Lbl 2 :Output(1,3,"DIFFICULTIES :Output(2,1,"---------------- :Output(3,1,"1: EASY :Output(4,2,"2: MEDIUM :Output(5,2,"3: HARD :Output(6,1,"4: CUSTOM :Output(7,1,"5: BACK :3→N

This code displays the difficulty screen. It also sets the cursor (**N**) to the first option (Row 3).

:Repeat max(FV={21,105,92,93,94,82,83 :getKey→FV :If FV=25 or FV=34 :Then :Output(N,1," " :N+(FV=34 andN≠7)-(FV=25 andN≠3→N:Output(N,1,"> :End :End

This code is the same as that from the main menu.

:ClrHome :If FV≠21 and FV≠105 :max({3,4,5,6,7}(FV={92,93,94,82,83→N:IfN=3 :{9,9,10→L1 :IfN=4 :{16,16,40→L1 :IfN=5 :{30,16,99→L1 :IfN=6 :prgmθMINECST :Goto 0

This area is also nearly identical to the main menu code. The difference is that instead of jumping to a label, it sets different values to L1. If you chose to make a custom field, it runs prgmθMINECST. Then it returns to the main menu.

:Lbl 3 :Output(1,7,"EASY :Output(4,7,"MEDIUM :Output(7,7,"HARD :For(X,2,8,3 :If not(iPart(log(L3((X+1)/3)))) or 1=iPart(log(L3((X+1)/3 :Output(X,8,L3((X+1)/3 :If 2=iPart(log(L3((X+1)/3 :Output(X,7,L3((X+1)/3 :End

This code displays the fastest times you got in each difficulty. The fancy math with log( commands is testing the length of the time. It then centers the number as well as it can.

:getKey :Repeat Ans=21 or Ans=105 :getKey :End :ClrHome :Goto 0

It then waits until you press a key, and returns to the main menu.

:Lbl 4 :Output(1,2,"RESET SCORES? :Output(2,1,"---------------- :Output(3,1,">CANCEL :Output(4,2,"RESET :3→N

This displays the men that asks if you want to reset your times.

:Repeat FV=21 or FV=105 :getKey→FV :If FV=25 or FV=34 :Then :Output(N,1," " :N+(FV=34 andN=3)-(FV=25 andN=4→N:Output(N,1,"> :End :End

This is still identical menu code, but pressing a number will not select an option. It makes it less likely to accidently reset your scores.

:ClrHome :IfN=4 :{999,999,999→L3 :Goto 0

If you chose to reset your scores, it makes them {999,999,999}. Then it returns to the main menu.

:Lbl 5 :Output(1,1,"MADE BY: :Output(3,7,"LORD :Output(4,8,"OF :Output(5,7,"THE :Output(6,6,"BLEAK

This displays that I made this game. I will be annoyed if you change this piece. I am watching you...

```
:prgmθMINESCR
```

This program saves and codes the high scores.

:DelVar L1DelVar L2DelVar L3DelVar [A]DelVar Pic1DelVar Pic2DelVar Pic3

This deletes all variables that were used in the program.

:getKey :0 :Repeat getKey or Ans≥200 :Ans+1 :End :ClrHome :Output(1,1,"

It then waits until you press a key or until it counts to 200. Then it clears the screen and the game ends.

### prgmθMINECLR Edit

:Text(57,0,"PLEASE WAIT... :checkTmr(1→N

This tells you to wait because it is doing something. It also checks the time. This process takes time, and it can check how long it takes and subtract that time from the total time you play it so that the time is only the time you are playing the game.

:N→U :I%→V :{N+.01I%→L2 :1→T

This code saves **N** and I% as U and V which aren't used for anything important. It stores **N** and I% as the only item in L2. It also sets T to 1, which is used later.

:While dim(L2

As long as L2 has items (spaces it still needs to clear), it will run.

:iPart(L2(dim(L2→N:E2fPart(L2(dim(L2→I%

It set's **N** and I% to the oldest item in the list.

:If .2≠fPart([A]((I%+5)/3,(N+5)/3 :Then

If the space is unflagged...

:prgmθMINESTP :prgmθMINEDRW

...it runs prgmθMINESTP and prgmθMINEDRW. These programs step on the space and then draw the correct image on the spot.

:If not([A]((I%+5)/3,(N+5)/3 :Then

If the space has no adjacent mines...

:For(X,N-3,N+3,3 :For(Y,I%-3,I%+3,3 :If fPart([A]((Y+5)/3,(X+5)/3)) and not(sum(L2=X+.01Y :augment({X+.01Y},L2→L2 :End :End :End :End

...then it will add every adjacent space to the list that has all the spaces that need to be stepped, provided the space isn't already on the list and it is unflagged and unstepped.

:-1+dim(L2→dim(L2 :End

It then subtracts the space it just tested from the list.

:PMT+1→PMT :U→N:V→I% :0→T :Pt-On(N,-I%,3 :Pt-Off(N,-I%

It resets all the variables that changed. During this process, PMT became off by 1 and needs to be fixed. This happens because PMT is decremented for the first item on the list twice. Once when it is first stepped on and once in this program. It then also redraws the cursor.

:getKey :For(X,-62,-57 :Line(0,X,64,X,0 :End :Text(57,0,PV :n+(checkTmr(1)-N→n

It then erases the wait message and redisplays PV. It also offsets the starting time by the time used doing this so that when it calculates the final time, this time is ignored.

### prgmθMINECST Edit

:Output(1,1,">X: [ :Output(2,2,"Y: [ :Output(3,2,"Z: [ :Output(1,6,L1(1 :Output(2,6,L1(2 :Output(3,6,L1(3 :Output(1,7+(L1(1)>9),"] :Output(2,7+(L1(2)>9),"] :Output(3,7+(L1(3)>9)+(L1(3)>99),"] :1→N:0→I%

This displays the menu for the custom field and sets the cursor. **N** is the row the cursor is on. I% is the value of the list item that is selected.

:Repeat (FV=105 or FV=21) and (not(max(L1=0)) and (L1(1)*L1(2)>L1(3

It repeats until you press 2nd or Alpha and and no item is 0 and the number of mines is less than the number of spaces.

:getKey→FV :If (FV=25 andN≠1) or (FV=34 andN≠3 :Then :Output(N,1," " :N+(FV=34)-(FV=25→N:Output(N,1,"> :End

If you press up or down, and you can move the cursor there, then it moves the cursor.

:If max(FV={92,93,94,82,83,84,72,73,74,102,23,45 :Then

If you press 0-9, DEL, or CLEAR, then it continues.

:If max(FV={92,93,94,82,83,84,72,73,74,102

If you pressed 0-9...

:10L1(N)+max({0,1,2,3,4,5,6,7,8,9}(FV={102,92,93,94,82,83,84,72,73,74→L1(N

...it adds the correct digit to the end of the value you are editing.

:If FV=23 :iPart(L1(N)/10→L1(N

If you press DEL, then it removes the last digit.

:If FV=45 :0→L1(N

If you pressed CLEAR, then it sets the value to 0.

:L1-(L1-{31,19,588})(L1>{31,19,588→L1

If you entered a value that is larger than the maximum value for that item, then it sets the item to the maximum value. The maximum field dimensions are as large as the screen is. The maximum mine value is 1 less than the maximum number of blocks.

:Output(N,6,Ans(N:Output(N,7+Ans(N)>9)+(Ans(N)>99),"] " :End :End

It redisplays the item you were editing.

### prgmθMINEDRW Edit

:Pt-Off(N,-I%,2 :Pt-Off(N,-I%

It erases the space that the cursor was on (or the space being stepped on if run from prgmθMINECLR).

:[A]((I%+5)/3,(N+5)/3

This is just here so I can use it as Ans.

:If fPart(Ans :Then :Pt-On(N,-I%,2 :Pt-On(N,-I% :End

If the space is unstepped, it blacks it out.

:If .2=fPart(Ans :Then :Pt-Off(N-1,-I% :Pt-Off(N-1,-I%-1 :Pt-Off(N,-I%-1 :End

If the space is flagged, it erases part of the blacked out area to make the flag drawing.

:If iPart(Ans) and not(fPart(Ans :Then

If it is stepped on...

:iPart(Ans :If Ans=2 or Ans≥4 :Pt-On(N-1,-I%+1 :If Ans=8 :Pt-On(N,-I%+1 :If Ans≥3 :Pt-On(N+1,-I%+1 :If Ans≥6 :Pt-On(N-1,-I% :If fPart(Ans/2 :Pt-On(N,-I% :If Ans≥6 :Pt-On(N+1,-I% :If Ans≥3 :Pt-On(N-1,-I%-1 :If Ans=8 :Pt-On(N,-I%-1 :If Ans=2 or Ans≥4 :Pt-On(N+1,-I%-1 :End

...then it uses 9 Pt-On( commands coupled with if commands to test which pixels get turned on. The result is the correct image. For example: the top left pixel is only used if the number is 2, 4, 5, 6, 7, or 8.

### prgmθMINEFCE Edit

:ClrDraw :Circle(47,-31,31,{i :Circle(37,-25,7,{i :Circle(57,-25,7,{i :For(X,225,315,3 :Pt-On(47+20cos(X),-31+20sin(X :End :StorePic 1

It displays a face, drawing the mouth using a For( loops with sin( and cos( and X as the angle. It is then saved.

:ClrDraw :Circle(47,-31,31,{i :Circle(37,-25,7,{i :Circle(57,-25,7,{i :For(X,45,135,3 :Pt-On(47+20cos(X),-62+20sin(X :End :StorePic 2

This does the same as the above.

:ClrDraw :Circle(47,-31,31,{i :Line(32,-15,42,-25 :Line(32,-25,42,-15 :Line(52,-15,62,-25 :Line(52,-25,62,-15 :Circle(47,-45,8,{i :StorePic 3 :ClrDraw

This part does the same, but with X'd out eyes and an open mouth.

Running this program saves time later so it doesn't have to be drawn every time a game ends.

### prgmθMINEGUI Edit

:Pt-Off(14,-61,2 :Pt-Off(14,-59,2 :Pt-Off(16,-61,2 :Pt-Off(16,-59,2

It clears the number already there.

:If FV=1 or .1=fPart([A]((I%+5)/3,(N+5)/3 :Return

If you are dead, or if the space is unstepped, it does nothing and exits.

:If fPart([A]((I%+5)/3,(N+5)/3 :Then :Pt-On(13,-58 :Pt-On(15,-58 :Pt-On(17,-58 :Pt-On(15,-60 :Pt-On(17,-60 :Pt-On(17,-62 :Else :iPart([A]((I%+5)/3,(N+5)/3 :If Ans=2 or Ans≥4 :Pt-On(13,-58 :If Ans=8 :Pt-On(15,-58 :If Ans≥3 :Pt-On(17,-58 :If Ans≥6 :Pt-On(13,-60 :If fPart(Ans/2 :Pt-On(15,-60 :If Ans≥6 :Pt-On(17,-60 :If Ans≥3 :Pt-On(13,-62 :If Ans=8 :Pt-On(15,-62 :If Ans=2 or Ans≥4 :Pt-On(17,-62 :End

The rest of this program is similar enough to prgmθMINEDRW with just different pixel locations.

### prgmθMINEMRK Edit

:iPart([A]((I%+5)/3,(N+5)/3))+.1not(fPart([A]((I%+5)/3,(N+5)/3))-.1→[A]((I%+5)/3,(N+5)/3

If the space was unflagged, it flags it. Otherwise, it unflagged it.

:PV+(fPart(Ans)=.1)-(fPart(Ans)=.2)→PV

It correctly changes PV to the new value so that it shows the new number of unflagged mines.

```
:Text(57,0,PV," "
:prgmθMINEGUI
```

It displays the new PV and runs prgmθMINEGUI.

### prgmθMINEMVE Edit

```
:prgmθMINEDRW
```

It runs this program to display the image that should be in the spot the cursor is moving from/

:N+3((FV=26)-(FV=24→N:I%+3((FV=34)-(FV=25→I%

It adjusts **N** and I% based on the keypresses (moves the cursor).

:Pt-Off(N,-I%,2 :Pt-On(N,-I%,3 :Pt-Off(N,-I%

It redraws the cursor.

```
:prgmθMINEGUI
```

It then displays the block you are standing on at the bottom of the screen.

### prgmθMINESCR Edit

:If not(dim(L3 :Then

If L3 is empty (the program is run at the beginning of the game)...

:iPart(LHMINE→L1 :fPart(LHMINE→L2

...it saves the integer of LHMINE (the scores) and the decimal (the unique values for the scores) as two lists.

:Else :L3→L1

Otherwise the program is being run at the end of the game and it sets the new high scores (without the decimal code) as L1.

:End :"^{2}√(e^(log()(tan^{-1}(X.1^{-1}X√ :seq(expr(sub(Ans,9,1)+sub(Ans,10,1)+sub(Ans,8,1)+sub(Ans,12,1)+sub(Ans,6,1)+sub(Ans,4,1)+sub(Ans,2,1)+sub(Ans,7,1)+sub(Ans,3,1)+sub(Ans,2,1)+"L1("+sub(Ans,8,1)+")"+sub(Ans,11,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,5,1)+sub(Ans,1,1)),X,1,3

This creates the decimal code that should apply to the score.

:If not(dim(L3 :Then :L1*(L2=Ans→L3 :L3-(L3-999)not(L3→L3

If the program is being run at the beginning of the game, it checks to make sure that the scores are untampered. If they aren't, it makes them 999 (only the tampered ones).

:Else :L3+Ans→LHMINE

If the program is being run at the end of the game, it saves the new coded high scores.

:End

### prgmθMINESET Edit

:If 9.1≠[A]((I%+5)/3,(N+5)/3 :Return

If the space is fine to step on, it exits this program and continues with the game.

:2→X :2→Y :While 9.1=[A](Y,X :Y+(X=L1(1)+1→Y :X+1-(X-1)(X=L1(1)+1→X :End :9.1→[A](Y,X

If the space is a mine, then it moves horizontally from the top, going down a row every time it reaches the end of the field, until it finds an empty space to put the mine.

### prgmθMINESHW Edit

:getKey :PV→X :PMT→Y :N→PV :I%→PMT :1→N:1→I%

This bumps **N** and I% to PV and PMT, and PV and PMT to X and Y.

:Repeat Ans=21 or Ans=105 or ((I%+5)/3)-1>L1(2

It repeats until it hits the last place or you press 2nd or ENTER.

:Pt-Off(N,-I%,2 :Pt-Off(N,-I%

It erases the spot.

:[A]((I%+5)/3,(N+5)/3 :If (9=iPart(Ans) and .2≠fPart(Ans)) or (FV=1 andN=PV and I%=PMT :Pt-On(N,-I%,3

If the space was an unflagged mine, it marks it as such.

:If .2=fPart(Ans :Then :If 9=iPart(Ans :Then :Pt-On(N-1,-I%+1 :Pt-On(N,-I%+1 :Pt-On(N+1,-I%+1 :Pt-On(N,-I% :Pt-On(N-1,-I% :Pt-On(N-1,-I%-1

If the space was a flagged mine, it reflags the space.

:Else :Pt-On(N,-I%,3 :Pt-Off(N,-I%

If the space was flagged and not a mine, it marks it as such.

:End :End :N+3→N

It moves the spot it is checking.

:If ((N+5)/3)-1>L1(1 :Then :1→N:I%+3→I% :End

If the spot hits the end of the field, it moves it down a row and to the other end.

:getKey :End

The getKey is used as Ans in the loop.

:If not(Ans :Then

If you didn't manually end the previous loop...

:1→N:Repeat Ans

...then it will repeat util you press a key.

:N+1-N(N≥40→N

**N** will increment but return to 0 if it reaches 40.

:If not(N:Pt-Off(PV,-PMT,2

If **N**=0 it draws just a single point.

:IfN=21 :Then :Pt-On(PV,-PMT,2 :Pt-Off(PV,-PMT,3 :End

If **N**=21 it draws a square minus a cross with a point in the center.

:IfN=0 orN=21 :Pt-On(PV,-PMT

This is the point in the middle that is always there.

:getKey :End :End

The result is an explosion animation on the mine you stepped on.

:X→PV :Y→PMT

It restores PV and PMT which need to be tested later on.

### prgmθMINESTP Edit

:If 9=iPart([A]((I%+5)/3,(N+5)/3 :1→FV :0 :For(X,-1+(N+5)/3,1+(N+5)/3 :For(Y,-1+(I%+5)/3,1+(I%+5)/3 :Ans+(9=iPart([A](Y,X :End :End :Ans→[A]((I%+5)/3,(N+5)/3 :PMT-1→PMT :If not(T :prgmθMINEGUI