' in 2003.12\r
' H-Page: svjatoslav.eu\r
' E-Mail: svjatoslav@svjatoslav.eu\r
- \r
-CLS\r
\r
+CLS\r
\r
1\r
-b = INP(&H3FD)\r
-IF b = 97 THEN\r
- b = INP(&H3F8)\r
- PRINT CHR$(b);\r
- PRINT b;\r
-END IF\r
-\r
-a$ = INKEY$\r
-\r
-IF a$ <> "" THEN\r
- PRINT a$;\r
- OUT &H3F8, ASC(a$)\r
-END IF\r
-GOTO 1\r
+ ' Read the status of the COM port\r
+ portStatus = INP(&H3FD)\r
+\r
+ ' Check if data is available\r
+ IF portStatus = 97 THEN\r
+ ' Read the data from the COM port\r
+ comData = INP(&H3F8)\r
+\r
+ ' Print the character and its ASCII value\r
+ PRINT CHR$(comData);\r
+ PRINT comData;\r
+ END IF\r
\r
+ ' Get user input\r
+ userInput$ = INKEY$\r
+\r
+ ' If there is any input, print it and send to COM port\r
+ IF userInput$ <> "" THEN\r
+ PRINT userInput$;\r
+\r
+ ' Send the ASCII value of the input character to the COM port\r
+ OUT &H3F8, ASC(userInput$)\r
+ END IF\r
+\r
+' Repeat the process\r
+GOTO 1\r
+++ /dev/null
-prt2 = &H379\r
-\r
-1\r
-PRINT INP(prt2);\r
-GOTO 1\r
-\r
+++ /dev/null
-SCREEN 12\r
-\r
-prt2 = &H379\r
-\r
-1\r
-FOR x = 0 TO 630\r
- c = INP(prt2)\r
- IF c <> 127 THEN\r
- y = y + 1\r
- ELSE\r
- IF y > 0 THEN y = y - 1\r
- END IF\r
- LINE (x + 6, 0)-(x + 6, 479), 12\r
- LINE (x, 0)-(x, 479), 0\r
- LINE (x, 0)-(x, y), 15\r
-\r
-'FOR a = 1 TO 1000\r
-'NEXT a\r
-NEXT x\r
-GOTO 1\r
-\r
+++ /dev/null
-SCREEN 13\r
-\r
-prt2 = &H379\r
-\r
-\r
-1\r
-IF INP(prt2) <> 127 THEN c = c + .1 ELSE c = c - .1\r
-\r
-IF c < 16 THEN c = 16\r
-IF c > 31 THEN c = 31\r
-\r
-LINE (100, 50)-(219, 150), c, BF\r
-GOTO 1\r
-\r
-' LPT current controller\r
-' made by Svjatoslav Agejenko\r
-' in 2002\r
-' H-Page: svjatoslav.eu\r
-' E-Mail: svjatoslav@svjatoslav.eu\r
-\r
-' Control current on LPT port pins,\r
-' use keys 1 - 8 to toggle on/off\r
-\r
-DECLARE SUB disp ()\r
-DECLARE SUB send ()\r
+' Program to control voltage on individual LPT port pins.\r
+' By Svjatoslav Agejenko.\r
+' Email: svjatoslav@svjatoslav.eu\r
+' Homepage: http://www.svjatoslav.eu\r
+'\r
+' Changelog:\r
+' 2002, Initial version\r
+' 2024.08, Improved program readability using AI\r
+'\r
+' Use keyboard keys 1 - 8 to toggle on/off individual pins.\r
+\r
+DECLARE SUB display ()\r
+DECLARE SUB transmit ()\r
DIM SHARED bit(1 TO 8)\r
-DIM SHARED prt\r
+DIM SHARED printerPort\r
\r
-prt = &H378\r
+printerPort = &H378\r
FOR a = 1 TO 8\r
-bit(a) = 0\r
+ bit(a) = 0\r
NEXT a\r
SCREEN 13\r
\r
-1\r
-disp\r
-send\r
-a$ = INPUT$(1)\r
-IF VAL(a$) > 0 THEN\r
-b = VAL(a$)\r
-IF bit(b) = 0 THEN bit(b) = 1 ELSE bit(b) = 0\r
+MainLoop:\r
+display\r
+transmit\r
+keyInput$ = INPUT$(1)\r
+IF VAL(keyInput$) > 0 THEN\r
+ keyValue = VAL(keyInput$)\r
+ IF bit(keyValue) = 0 THEN\r
+ bit(keyValue) = 1\r
+ ELSE\r
+ bit(keyValue) = 0\r
+ END IF\r
END IF\r
\r
-GOTO 1\r
-\r
-SUB disp\r
+GOTO MainLoop\r
\r
-LOCATE 3, 1\r
-PRINT " 1 2 3 4 5 6 7 8"\r
-\r
-FOR a = 1 TO 8\r
-LINE (a * 16, 1)-(a * 16 + 8, 9), bit(a), BF\r
-NEXT a\r
+SUB display\r
\r
+ ' Display the current status of each pin\r
+ LOCATE 3, 1\r
+ PRINT " 1 2 3 4 5 6 7 8"\r
\r
+ FOR a = 1 TO 8\r
+ LINE (a * 16, 1)-(a * 16 + 8, 9), bit(a), BF\r
+ NEXT a\r
\r
END SUB\r
\r
-SUB send\r
+SUB transmit\r
\r
-b = 0\r
-FOR a = 1 TO 8\r
-b = b * 2\r
-b = b + bit(a)\r
-NEXT a\r
+ ' Calculate the byte to be sent based on the status of each pin\r
+ outputByte = 0\r
+ FOR a = 1 TO 8\r
+ outputByte = outputByte * 2\r
+ outputByte = outputByte + bit(a)\r
+ NEXT a\r
\r
-OUT prt, b\r
+ OUT printerPort, outputByte\r
END SUB\r
-\r
+++ /dev/null
-' Monitor LPT pin state\r
-' made by Svjatoslav Agejenko\r
-' in 2002\r
-' H-Page: svjatoslav.eu\r
-' E-Mail: svjatoslav@svjatoslav.eu\r
- \r
-\r
-' Monitors LPT1 pins 14, 16, 17 and some others.\r
-\r
-\r
-DECLARE SUB display ()\r
-DIM SHARED frm\r
-SCREEN 13\r
-\r
-\r
-OUT &H37A, 0\r
-\r
-1\r
-display\r
-\r
-GOTO 1\r
-\r
-SUB display\r
-\r
-a = INP(&H37A)\r
-b = 128\r
-LOCATE 5, 1\r
-PRINT a\r
-\r
-FOR c = 1 TO 8\r
-IF a >= b THEN a = a - b: d = 3 ELSE d = 1\r
-b = b / 2\r
-CIRCLE (c * 10, 10), 4, d\r
-PAINT (c * 10, 10), d\r
-NEXT c\r
-\r
-END SUB\r
-\r
+++ /dev/null
-; by: Svjatoslav Agejenko\r
-; homepage: svjatoslav.eu\r
-; email: svjatoslav@svjatoslav.eu\r
-; on: 2002.10.07\r
-; compile with FASM ( Flat ASseMbler ) by Tomasz Grysztar\r
-\r
-org 100h\r
-\r
-cmaddr = 53h\r
-\r
-\r
- mov ah, 3ch ; create file\r
- sub cx, cx\r
- mov dx, name\r
- int 21h\r
- mov [hand], ax\r
-\r
- mov al, cmaddr\r
- out 70h, al\r
- in al, 71h\r
- \r
- mov di, eof\r
- sub cx, cx\r
- mov cl, al\r
- mov dl, cmaddr\r
-\r
-l1: inc dl\r
- mov al, dl\r
- out 70h, al\r
- in al, 71h\r
- stosb\r
- loop l1\r
-\r
- mov cx, di ; write to file\r
- sub cx, line\r
- mov ah, 40h\r
- mov bx, [hand]\r
- mov dx, line\r
- int 21h\r
-\r
- mov ah, 3eh ; close file\r
- mov bx, [hand]\r
- int 21h\r
-\r
- ret\r
-\r
-error: mov ah, 9\r
- mov dx, err\r
- int 21h\r
- ret\r
-\r
-name db 'setenv.bat', 0\r
-hand dw 0\r
-err db 'error occured$'\r
-line db 'SET CMOSE='\r
-eof:\r
+++ /dev/null
-DECLARE SUB displayit ()\r
-DECLARE SUB newstring ()\r
-DECLARE SUB start ()\r
-DIM SHARED adr\r
-DIM SHARED maxlen\r
-\r
-start\r
-\r
-2\r
-PRINT " "\r
-displayit\r
-PRINT " "\r
-PRINT "1 - to enter new string"\r
-PRINT "2 - to quit"\r
-a$ = INPUT$(1)\r
-SELECT CASE a$\r
- CASE "1"\r
- newstring\r
- CASE "2"\r
- SYSTEM\r
- CASE ELSE\r
- PRINT "unrecognized command"\r
-END SELECT\r
-\r
-GOTO 2\r
-\r
-SUB displayit\r
-PRINT "Current CMOS contains: ";\r
-OUT &H70, adr\r
-l = INP(&H71)\r
-\r
-IF l > maxlen THEN PRINT "<empty>": GOTO 1\r
-COLOR 0, 15\r
-FOR a = 1 TO l\r
- OUT &H70, adr + a\r
- PRINT CHR$(INP(&H71));\r
-NEXT a\r
-COLOR 7, 0\r
-PRINT " "\r
-1\r
-\r
-END SUB\r
-\r
-SUB newstring\r
-PRINT " max length |" + SPACE$(maxlen) + "|"\r
-INPUT "Enter new string:", a$\r
-IF LEN(a$) > maxlen THEN PRINT "too long, max"; maxlen: GOTO 3\r
-\r
-OUT &H70, adr\r
-OUT &H71, LEN(a$)\r
-\r
-FOR b = 1 TO LEN(a$)\r
- c = ASC(RIGHT$(LEFT$(a$, b), 1))\r
- OUT &H70, adr + b\r
- OUT &H71, c\r
-NEXT b\r
-\r
-3\r
-END SUB\r
-\r
-SUB start\r
-adr = 83\r
-maxlen = 8\r
-\r
-CLS\r
-PRINT "Svjatoslav Agejenko"\r
-PRINT "svjatoslav@svjatoslav.eu"\r
-PRINT "2002.10.07"\r
-PRINT " "\r
-PRINT "Utility to store max"; maxlen; "character long string in CMOS memory."\r
-PRINT "beginning CMOS address: 0x"; HEX$(adr)\r
-\r
-END SUB\r
-\r