-' Svjatoslav Agejenko 2003.01\r
-' svjatoslav@svjatoslav.eu\r
+' This application produces beautiful colorful horizontal rainbows on the screen in text mode.\r
+' It works only on CRT monitors, because it accomplishes the effect by changing the color palette\r
+' while the CRT monitor is drawing the screen. As a result, unlimited number of colors can be\r
+' displayed on the screen simultaneously, regardless of the video card's color depth.\r
+'\r
+' By Svjatoslav Agejenko.\r
+' Email: svjatoslav@svjatoslav.eu\r
+' Homepage: http://www.svjatoslav.eu\r
+\r
+' Changelog:\r
+' 2003.01, Initial version\r
+' 2024, Improved program readability\r
\r
DEFINT A-Z\r
CLS\r
COLOR 7\r
\r
+' Fill background with random colored random numbers.\r
FOR b = 1 TO 500\r
-COLOR RND * 15\r
-PRINT RND;\r
+ COLOR RND * 15\r
+ PRINT RND;\r
NEXT b\r
\r
+' Set the background and text colors\r
COLOR 0, 1\r
+\r
+' Clear rectangular area\r
FOR y = 5 TO 20\r
-FOR x = 20 TO 50\r
-LOCATE y, x\r
-PRINT " "\r
-NEXT x\r
+ FOR x = 20 TO 50\r
+ LOCATE y, x\r
+ PRINT " "\r
+ NEXT x\r
NEXT y\r
+\r
+' Print "[ TEST ]" at position (10, 25)\r
LOCATE 10, 25\r
PRINT "[ TEST ]"\r
\r
+' Print "[ TEST ]" in color 2 at position (15, 37)\r
LOCATE 15, 37\r
COLOR 2\r
PRINT "[ TEST ]"\r
\r
+' Initialize variables\r
wa = 1\r
p = &H3DA\r
+\r
+' Loop to wait until CRT monitor has drawn single frame\r
1\r
+' measure how much time was spent waiting for screen redraw to complete\r
w = w + 1\r
+\r
+' Check if monitor is still drawing frame\r
a = INP(p)\r
IF a >= 128 THEN a = a - 128\r
IF a >= 64 THEN a = a - 64\r
frm = frm + 1\r
IF frm > 10000 THEN frm = -10000\r
\r
-\r
+' Adjust the color palette change speed so that it takes approximately all of the time\r
+' when Ray is actually moving along screen surface and is drawing pixels.\r
+' So if we had to wait too long for drawing to complete at the end, it means\r
+' next frame we can be slower with our palette updates.\r
IF w > 300 THEN wa = wa + 1 ELSE wa = wa - 1\r
IF w < 250 THEN wa = wa - 5\r
IF w > 3000 THEN wa = wa + 30\r
IF w > 1000 THEN wa = wa + 5\r
\r
+' Check if a key has been pressed\r
IF INKEY$ <> "" THEN\r
- OUT &H3C8, 0\r
- OUT &H3C9, 0\r
- OUT &H3C9, 0\r
- OUT &H3C9, 0\r
- SYSTEM\r
+ ' Reset color palette\r
+ OUT &H3C8, 0\r
+ OUT &H3C9, 0\r
+ OUT &H3C9, 0\r
+ OUT &H3C9, 0\r
+ ' exit application\r
+ SYSTEM\r
END IF\r
\r
+' Alter video graphics color palette while CRT screen in drawing scanlines simultaneously\r
FOR a = 0 TO 70\r
- b = a * 6 + frm\r
- OUT &H3C8, 0\r
- OUT &H3C9, SIN(b / 20) * 30 + 30\r
- OUT &H3C9, SIN(b / 27) * 30 + 30\r
- OUT &H3C9, SIN(b / 31) * 30 + 30\r
- FOR u = 1 TO wa\r
- NEXT u\r
+\r
+ b = a * 6 + frm\r
+\r
+ ' Alter palette within video card\r
+ OUT &H3C8, 0\r
+ OUT &H3C9, SIN(b / 20) * 30 + 30\r
+ OUT &H3C9, SIN(b / 27) * 30 + 30\r
+ OUT &H3C9, SIN(b / 31) * 30 + 30\r
+\r
+ ' Delay to give time for CRT screen to complete horizontal scanlines\r
+ FOR u = 1 TO wa\r
+ NEXT u\r
NEXT a\r
\r
w = 0\r
GOTO 1\r
-\r