ARTILLERY.BAS - Mermaid Flow Diagrams

Interactive flowcharts showing program structure and control flow

Main Program Flow

flowchart TD Start([START
Lines 5-10]) --> InputInst{Instructions?
Line 15-16} InputInst -->|NO| ShowInst[Show Instructions
Lines 20-140
Print text & GET key] InputInst -->|YES| InitGame ShowInst --> InitGame[Initialize Graphics
Lines 150-160
HGR, HCOLOR=6] InitGame --> InitGuns[Generate Gun Positions
Lines 170-190
G1, G2 random] InitGuns -->|G1,G2 too close| InitGuns InitGuns --> InitWind[Initialize Wind
Lines 200-230
W1 speed, W2 direction] InitWind --> DrawGuns[Draw Guns
Lines 240-340
Both cannons] DrawGuns --> CallMountain[GOSUB 1440
Draw Mountain
Line 360] CallMountain --> CallPlayer1[GOSUB 1630
Set Player Position
Line 370] CallPlayer1 --> LoopX8[FOR X8 = 1 TO 20
Game Turns Loop
Line 380] LoopX8 --> SwitchPlayer[Switch Player
Lines 390-400
P1 = P1 * -1] SwitchPlayer --> CallIndic[GOSUB 1290
Draw Indicator
Line 410] CallIndic --> CallWind[GOSUB 1580
Print Wind Info
Line 420] CallWind --> InputShot[Input Angle & Velocity
Lines 430-440
A1 20-100, V1 45-150] InputShot --> ValidateInput{Valid Input?
Lines 441-442} ValidateInput -->|NO| ErrorMsg[Print Error
Line 445] ErrorMsg -->|GOTO 430| InputShot ValidateInput -->|YES| CalcTraj[Calculate Trajectory
Lines 450-510
Convert angle, calc params] CalcTraj --> LoopY8[FOR Y8 = 0 TO T1 STEP T2
Trajectory Loop
Line 520] LoopY8 --> CalcPos[Calculate Position
Lines 530-580
X, Y with wind effect] CalcPos --> CheckLow{Y < 9?
Line 590} CheckLow -->|YES GOTO 750| CheckHit CheckLow -->|NO| CheckPlayer{P1 < 0?
Line 600} CheckPlayer -->|YES Right Gun| PlotRight[Plot Right Shot
Lines 680-730
HCOLOR=3 White] CheckPlayer -->|NO Left Gun| PlotLeft[Plot Left Shot
Lines 610-660
HCOLOR=5 Orange] PlotRight --> CheckHit[GOSUB 1060
Check Mountain Hit
Line 750] PlotLeft --> CheckHit CheckHit --> CheckP2{P2 = 5?
Mountain Hit?
Line 760} CheckP2 -->|YES GOTO 800| DrawExplosion CheckP2 -->|NO| NextY8[NEXT Y8
Line 770] NextY8 --> LoopY8 DrawExplosion[GOSUB 1160
Draw Explosion
Line 790] DrawExplosion --> CheckGun1{Hit G1?
Line 800} CheckGun1 -->|YES| RightWins[Right Gun Wins
Lines 820-830
T3++] CheckGun1 -->|NO| CheckGun2{Hit G2?
Line 850} CheckGun2 -->|YES| LeftWins[Left Gun Wins
Lines 870-880
T4++] RightWins -->|GOTO 930| PlayAgain LeftWins -->|GOTO 930| PlayAgain CheckGun2 -->|NO Miss| NextX8[NEXT X8
Line 920] NextX8 --> LoopX8 PlayAgain{Play Again?
Lines 930-951} PlayAgain -->|YES GOTO 150| InitGame PlayAgain -->|NO| ShowScore[Show Final Score
Lines 990-1020
T3 Right, T4 Left] ShowScore --> End([END
Line 1050]) style Start fill:#fff3e0,stroke:#f57c00,stroke-width:3px style End fill:#ffebee,stroke:#c62828,stroke-width:3px style InputInst fill:#fff9c4,stroke:#f9a825,stroke-width:2px style ValidateInput fill:#fff9c4,stroke:#f9a825,stroke-width:2px style CheckLow fill:#fff9c4,stroke:#f9a825,stroke-width:2px style CheckPlayer fill:#fff9c4,stroke:#f9a825,stroke-width:2px style CheckP2 fill:#fff9c4,stroke:#f9a825,stroke-width:2px style CheckGun1 fill:#fff9c4,stroke:#f9a825,stroke-width:2px style CheckGun2 fill:#fff9c4,stroke:#f9a825,stroke-width:2px style PlayAgain fill:#fff9c4,stroke:#f9a825,stroke-width:2px style LoopX8 fill:#e8f5e9,stroke:#388e3c,stroke-width:2px style LoopY8 fill:#e8f5e9,stroke:#388e3c,stroke-width:2px style NextX8 fill:#e8f5e9,stroke:#388e3c,stroke-width:2px style NextY8 fill:#e8f5e9,stroke:#388e3c,stroke-width:2px style InputShot fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px style RightWins fill:#ffebee,stroke:#c62828,stroke-width:2px style LeftWins fill:#ffebee,stroke:#c62828,stroke-width:2px

Subroutines Detail

flowchart TD subgraph SUB1060["SUBROUTINE 1060: Check Mountain Hit"] S1060Start([Enter SUB 1060
Line 1060]) --> S1060Init[Initialize Y6=150
Line 1060] S1060Init --> S1060Calc[Calculate Mountain Bounds
Lines 1070-1080
G8 = Y7 + 2*G3
Y7 = G1 + G2] S1060Calc --> S1060Check1{Y > G3?
Line 1090} S1060Check1 -->|YES| S1060Return S1060Check1 -->|NO| S1060Check2{G4 < Y7+Y?
Line 1100} S1060Check2 -->|YES| S1060Return S1060Check2 -->|NO| S1060Check3{G4 > G8-Y?
Line 1110} S1060Check3 -->|YES| S1060Return S1060Check3 -->|NO Hit!| S1060Hit[Set P2 = 5
Lines 1120-1130
Y6 = 150-Y] S1060Hit --> S1060Draw[Draw Explosion
FOR Z=1 TO 5
Lines 1160-1240
HPLOT explosion] S1060Draw --> S1060Switch[GOSUB 1630
Switch Player
Line 1270] S1060Switch --> S1060Return([RETURN
Line 1280]) end subgraph SUB1290["SUBROUTINE 1290: Draw Player Indicator"] S1290Start([Enter SUB 1290
Line 1290]) --> S1290Check{P1 < 0?
Line 1290} S1290Check -->|NO Left| S1290Left[Draw Left Indicator
Lines 1300-1330
HPLOT 1,152-155] S1290Left --> S1290Check2{P1 < 0?
Line 1340} S1290Check2 -->|YES| S1290Color2 S1290Check2 -->|NO| S1290Color1[HCOLOR = 0
Line 1350] S1290Check -->|YES Right| S1290Right[Draw Right Indicator
Lines 1360-1390
HPLOT 250,152-155] S1290Color1 --> S1290Right S1290Right --> S1290Clear[HCOLOR = 0
Line 1400] S1290Clear --> S1290Check3{P1 < 0?
Line 1410} S1290Check3 -->|YES| S1290Left S1290Check3 -->|NO| S1290Color2[HCOLOR = 2
Line 1420] S1290Color2 --> S1290Return([RETURN
Line 1430]) end subgraph SUB1440["SUBROUTINE 1440: Draw Mountain"] S1440Start([Enter SUB 1440
Line 1440]) --> S1440Calc1[Calculate G1
G1 = G2-G1 / 2
Line 1440] S1440Calc1 --> S1440Rand1[Random G2
Line 1450] S1440Rand1 --> S1440Rand2[Random G3
Line 1460] S1440Rand2 --> S1440Check1{G3 < 30?
Line 1470} S1440Check1 -->|YES| S1440Rand2 S1440Check1 -->|NO| S1440Check2{G2-G1+G2
> 2*G3?
Line 1480} S1440Check2 -->|NO| S1440Dec[G3 = G3 - 1
Line 1490] S1440Dec --> S1440Check2 S1440Check2 -->|YES| S1440Ground[Draw Ground
Lines 1510-1540
FOR M1=1 TO 252
HPLOT orange line] S1440Ground --> S1440Mount[Draw Mountain
Lines 1550-1560
Two HPLOT lines
Triangle shape] S1440Mount --> S1440Return([RETURN
Line 1570]) end style S1060Start fill:#fce4ec,stroke:#c2185b,stroke-width:2px style S1290Start fill:#fce4ec,stroke:#c2185b,stroke-width:2px style S1440Start fill:#fce4ec,stroke:#c2185b,stroke-width:2px style S1060Return fill:#e1bee7,stroke:#8e24aa,stroke-width:2px style S1290Return fill:#e1bee7,stroke:#8e24aa,stroke-width:2px style S1440Return fill:#e1bee7,stroke:#8e24aa,stroke-width:2px
flowchart TD subgraph SUB1160["SUBROUTINE 1160: Draw Explosion"] S1160Start([Enter SUB 1160
Line 1160]) --> S1160Loop[FOR Z = 1 TO 5
Line 1160] S1160Loop --> S1160Check{G4 in bounds?
0-253?
Line 1170} S1160Check -->|NO| S1160Next S1160Check -->|YES| S1160Plot[HPLOT Explosion Pattern
Lines 1180-1230
5 HPLOT statements
Star pattern] S1160Plot --> S1160Next[NEXT Z
Line 1240] S1160Next --> S1160Loop S1160Loop -->|Done| S1160Clear[Clear X, Y
Lines 1250-1260] S1160Clear --> S1160Call[GOSUB 1630
Line 1270] S1160Call --> S1160Return([RETURN
Line 1280]) end subgraph SUB1580["SUBROUTINE 1580: Print Wind Direction"] S1580Start([Enter SUB 1580
Line 1580]) --> S1580Check{W2 < 0?
Line 1580} S1580Check -->|NO| S1580Right[PRINT Wind Right
Line 1590] S1580Check -->|YES| S1580Left[PRINT Wind Left
Line 1610] S1580Right --> S1580Return([RETURN
Line 1620]) S1580Left --> S1580Return end subgraph SUB1630["SUBROUTINE 1630: Set Player Position"] S1630Start([Enter SUB 1630
Line 1630]) --> S1630Check{P1 < 0?
Line 1630} S1630Check -->|NO| S1630Right[Set Right Position
Line 1640
X2=G2, Y2=150] S1630Check -->|YES| S1630Left[Set Left Position
Line 1660
X2=G1, Y2=150] S1630Right --> S1630Return([RETURN
Line 1670]) S1630Left --> S1630Return end style S1160Start fill:#fce4ec,stroke:#c2185b,stroke-width:2px style S1580Start fill:#fce4ec,stroke:#c2185b,stroke-width:2px style S1630Start fill:#fce4ec,stroke:#c2185b,stroke-width:2px style S1160Return fill:#e1bee7,stroke:#8e24aa,stroke-width:2px style S1580Return fill:#e1bee7,stroke:#8e24aa,stroke-width:2px style S1630Return fill:#e1bee7,stroke:#8e24aa,stroke-width:2px

Complete Program Structure

graph TD Start([ARTILLERY START]) --> Init[Initialize & Setup
Lines 5-160] Init --> Setup[Setup Phase] Setup --> |170-190| GunPos[Gun Positions] Setup --> |200-230| Wind[Wind Parameters] Setup --> |240-340| DrawGuns[Draw Guns] DrawGuns --> Mountain[SUB 1440
Draw Mountain] Mountain --> PlayerInit[SUB 1630
Init Player] PlayerInit --> GameLoop{Game Loop
X8: 1-20} GameLoop --> Turn[Player Turn] Turn --> |400| Switch[Switch Player P1] Turn --> |410| Indicator[SUB 1290
Player Indicator] Turn --> |420| WindMsg[SUB 1580
Wind Message] WindMsg --> Input[Input A1, V1] Input --> |441-445| Validate{Valid?} Validate -->|NO| Input Validate -->|YES| Trajectory[Calculate Trajectory
450-510] Trajectory --> ProjectileLoop{Projectile Loop
Y8: 0-T1} ProjectileLoop --> CalcXY[Calculate X,Y
530-580] CalcXY --> |590| GroundCheck{Y < 9?} GroundCheck -->|YES| EndShot[End Shot] GroundCheck -->|NO| PlotShot[Plot Shot
600-730] PlotShot --> MountainCheck[SUB 1060
Check Hit] MountainCheck --> |760| HitCheck{Mountain
Hit?} HitCheck -->|YES| Explode[SUB 1160
Explosion] HitCheck -->|NO| ProjectileLoop Explode --> WinCheck{Hit Gun?} EndShot --> WinCheck WinCheck -->|G1| RWin[Right Wins
T3++] WinCheck -->|G2| LWin[Left Wins
T4++] WinCheck -->|Miss| GameLoop RWin --> Again{Play
Again?} LWin --> Again GameLoop -->|20 turns| Again Again -->|YES| Setup Again -->|NO| Score[Show Score
990-1020] Score --> End([END]) style Start fill:#4caf50,stroke:#2e7d32,stroke-width:3px,color:#fff style End fill:#f44336,stroke:#c62828,stroke-width:3px,color:#fff style GameLoop fill:#ff9800,stroke:#e65100,stroke-width:2px style ProjectileLoop fill:#ff9800,stroke:#e65100,stroke-width:2px style Mountain fill:#e91e63,stroke:#880e4f,stroke-width:2px,color:#fff style PlayerInit fill:#e91e63,stroke:#880e4f,stroke-width:2px,color:#fff style Indicator fill:#e91e63,stroke:#880e4f,stroke-width:2px,color:#fff style WindMsg fill:#e91e63,stroke:#880e4f,stroke-width:2px,color:#fff style MountainCheck fill:#e91e63,stroke:#880e4f,stroke-width:2px,color:#fff style Explode fill:#e91e63,stroke:#880e4f,stroke-width:2px,color:#fff style RWin fill:#ffeb3b,stroke:#f57f17,stroke-width:2px style LWin fill:#ffeb3b,stroke:#f57f17,stroke-width:2px

Program Structure Overview