-' Program to render animation inspired by movie.\r
+' Program to render animation inspired by opening scene from The Matrix movie.\r
' By Svjatoslav Agejenko.\r
' Email: svjatoslav@svjatoslav.eu\r
' Homepage: http://www.svjatoslav.eu\r
-'\r
+\r
' Changelog:\r
' 2002, Initial version\r
-' 2024.08, Improved program readability using AI\r
+' 2024, Improved program readability using AI\r
\r
DEFINT A-Z\r
-DECLARE SUB PutMatrix ()\r
-DIM SHARED array(1 TO 20)\r
-DIM SHARED length\r
-DIM SHARED message$\r
+DECLARE SUB DisplayMatrix ()\r
+DIM SHARED matrixArray(1 TO 20)\r
+DIM SHARED lineLength\r
+DIM SHARED displayMessage$\r
RANDOMIZE 2\r
\r
CLS\r
COLOR 10, 0\r
-message$ = ""\r
-counter = 0\r
-iteration = 0\r
-PutMatrix\r
+displayMessage$ = ""\r
+frameCounter = 0\r
+iterationCount = 0\r
+DisplayMatrix\r
\r
1 : ' Label for looping\r
-frequency = 0\r
-IF iteration >= 3 THEN frequency = 10000: iteration = 0\r
-SOUND frequency, .2\r
-counter = counter + 1\r
-iteration = iteration + 1\r
-IF counter > 100 THEN PutMatrix: counter = 0\r
+\r
+' Creates high-pitch pulsing sound by toggling it on and off while iterating\r
+soundFrequency = 0\r
+IF iterationCount >= 3 THEN soundFrequency = 10000: iterationCount = 0\r
+SOUND soundFrequency, .2\r
+iterationCount = iterationCount + 1\r
+\r
+frameCounter = frameCounter + 1\r
+IF frameCounter > 100 THEN DisplayMatrix: frameCounter = 0\r
\r
displayLine$ = ""\r
-lineCounter = 1\r
+lineIndex = 1\r
FOR column = 1 TO 80\r
- lineCounter = lineCounter + 1\r
- char$ = CHR$(INT(RND * 9) + 48)\r
- IF lineCounter > length THEN lineCounter = 1: char$ = " "\r
- displayLine$ = displayLine$ + char$\r
+ lineIndex = lineIndex + 1\r
+ randomCharacter$ = CHR$(INT(RND * 9) + 48)\r
+ IF lineIndex > lineLength THEN lineIndex = 1: randomCharacter$ = " "\r
+ displayLine$ = displayLine$ + randomCharacter$\r
NEXT column\r
LOCATE 25, 1\r
PRINT displayLine$\r
IF INKEY$ <> "" THEN COLOR 7, 0: CLS : SYSTEM\r
GOTO 1\r
\r
-SUB PutMatrix\r
+SUB DisplayMatrix\r
+ ' Set the viewport to print from line 1 to line 25\r
VIEW PRINT 1 TO 25\r
- SELECT CASE length\r
+\r
+ ' Display a message based on the code decoding progress\r
+ SELECT CASE lineLength\r
CASE 13\r
- message$ = "Are you sure the line is clear?"\r
+ displayMessage$ = "Are you sure the line is clear?"\r
CASE 6\r
- message$ = " Then I'll go ..."\r
+ displayMessage$ = " Then I'll go ..."\r
END SELECT\r
\r
+ ' Clear and print the message at position (1, 30)\r
LOCATE 1, 30\r
- PRINT " ";\r
+ PRINT " "\r
LOCATE 1, 30\r
- PRINT message$\r
+ PRINT displayMessage$\r
\r
randomValue = INT(RND * 9) + 1\r
FOR pass = 1 TO 3\r
FOR value = randomValue TO 10\r
- IF array(value) = -1 THEN\r
- array(value) = INT(RND * 8) + 1\r
- length = length - 1\r
+ IF matrixArray(value) = -1 THEN\r
+ ' Assign a random value between 1 and 8 to the array element\r
+ matrixArray(value) = INT(RND * 8) + 1\r
+ lineLength = lineLength - 1\r
GOTO 2\r
END IF\r
NEXT value\r
+ ' Reset randomValue if no valid position is found\r
randomValue = 1\r
NEXT pass\r
\r
- length = 13\r
+ ' Reset the length and initialize the array\r
+ lineLength = 13\r
FOR index = 1 TO 20\r
- array(index) = -1\r
+ matrixArray(index) = -1\r
NEXT index\r
\r
CLS\r
- IF message$ <> "" THEN SYSTEM\r
+ IF displayMessage$ <> "" THEN SYSTEM\r
\r
2 : ' Label for continuing after GOTO\r
FOR index = 1 TO 20\r
LOCATE 1, index\r
- IF array(index) = -1 THEN displayChar$ = " " ELSE displayChar$ = STR$(array(index))\r
+ ' Display a space if the array element is -1, otherwise display the value\r
+ IF matrixArray(index) = -1 THEN displayChar$ = " " ELSE displayChar$ = STR$(matrixArray(index))\r
displayChar$ = RIGHT$(displayChar$, 1)\r
PRINT displayChar$\r
NEXT index\r
\r
+ ' Set the viewport to print from line 2 to line 25\r
VIEW PRINT 2 TO 25\r
END SUB\r
-\r