From: Svjatoslav Agejenko Date: Thu, 5 Sep 2024 22:30:10 +0000 (+0300) Subject: Using AI to improve code readability. Remove unneeded programs. X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=35dd0fb878153d9e713df261f85ba93b40dd4a9d;p=qbasicapps.git Using AI to improve code readability. Remove unneeded programs. --- diff --git a/Networking/comterm.bas b/Networking/comterm.bas index b9d4c92..f60bb6e 100755 --- a/Networking/comterm.bas +++ b/Networking/comterm.bas @@ -3,23 +3,33 @@ ' in 2003.12 ' H-Page: svjatoslav.eu ' E-Mail: svjatoslav@svjatoslav.eu - -CLS +CLS 1 -b = INP(&H3FD) -IF b = 97 THEN - b = INP(&H3F8) - PRINT CHR$(b); - PRINT b; -END IF - -a$ = INKEY$ - -IF a$ <> "" THEN - PRINT a$; - OUT &H3F8, ASC(a$) -END IF -GOTO 1 + ' Read the status of the COM port + portStatus = INP(&H3FD) + + ' Check if data is available + IF portStatus = 97 THEN + ' Read the data from the COM port + comData = INP(&H3F8) + + ' Print the character and its ASCII value + PRINT CHR$(comData); + PRINT comData; + END IF + ' Get user input + userInput$ = INKEY$ + + ' If there is any input, print it and send to COM port + IF userInput$ <> "" THEN + PRINT userInput$; + + ' Send the ASCII value of the input character to the COM port + OUT &H3F8, ASC(userInput$) + END IF + +' Repeat the process +GOTO 1 diff --git a/Networking/monitor.bas b/Networking/monitor.bas deleted file mode 100755 index 9c1a779..0000000 --- a/Networking/monitor.bas +++ /dev/null @@ -1,6 +0,0 @@ -prt2 = &H379 - -1 -PRINT INP(prt2); -GOTO 1 - diff --git a/Networking/monitor2.bas b/Networking/monitor2.bas deleted file mode 100755 index 28ff509..0000000 --- a/Networking/monitor2.bas +++ /dev/null @@ -1,21 +0,0 @@ -SCREEN 12 - -prt2 = &H379 - -1 -FOR x = 0 TO 630 - c = INP(prt2) - IF c <> 127 THEN - y = y + 1 - ELSE - IF y > 0 THEN y = y - 1 - END IF - LINE (x + 6, 0)-(x + 6, 479), 12 - LINE (x, 0)-(x, 479), 0 - LINE (x, 0)-(x, y), 15 - -'FOR a = 1 TO 1000 -'NEXT a -NEXT x -GOTO 1 - diff --git a/Networking/monitor3.bas b/Networking/monitor3.bas deleted file mode 100755 index 0690799..0000000 --- a/Networking/monitor3.bas +++ /dev/null @@ -1,14 +0,0 @@ -SCREEN 13 - -prt2 = &H379 - - -1 -IF INP(prt2) <> 127 THEN c = c + .1 ELSE c = c - .1 - -IF c < 16 THEN c = 16 -IF c > 31 THEN c = 31 - -LINE (100, 50)-(219, 150), c, BF -GOTO 1 - diff --git a/Networking/prt.bas b/Networking/prt.bas index 5a564d2..2bd5a91 100755 --- a/Networking/prt.bas +++ b/Networking/prt.bas @@ -1,55 +1,60 @@ -' LPT current controller -' made by Svjatoslav Agejenko -' in 2002 -' H-Page: svjatoslav.eu -' E-Mail: svjatoslav@svjatoslav.eu - -' Control current on LPT port pins, -' use keys 1 - 8 to toggle on/off - -DECLARE SUB disp () -DECLARE SUB send () +' Program to control voltage on individual LPT port pins. +' By Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2002, Initial version +' 2024.08, Improved program readability using AI +' +' Use keyboard keys 1 - 8 to toggle on/off individual pins. + +DECLARE SUB display () +DECLARE SUB transmit () DIM SHARED bit(1 TO 8) -DIM SHARED prt +DIM SHARED printerPort -prt = &H378 +printerPort = &H378 FOR a = 1 TO 8 -bit(a) = 0 + bit(a) = 0 NEXT a SCREEN 13 -1 -disp -send -a$ = INPUT$(1) -IF VAL(a$) > 0 THEN -b = VAL(a$) -IF bit(b) = 0 THEN bit(b) = 1 ELSE bit(b) = 0 +MainLoop: +display +transmit +keyInput$ = INPUT$(1) +IF VAL(keyInput$) > 0 THEN + keyValue = VAL(keyInput$) + IF bit(keyValue) = 0 THEN + bit(keyValue) = 1 + ELSE + bit(keyValue) = 0 + END IF END IF -GOTO 1 - -SUB disp +GOTO MainLoop -LOCATE 3, 1 -PRINT " 1 2 3 4 5 6 7 8" - -FOR a = 1 TO 8 -LINE (a * 16, 1)-(a * 16 + 8, 9), bit(a), BF -NEXT a +SUB display + ' Display the current status of each pin + LOCATE 3, 1 + PRINT " 1 2 3 4 5 6 7 8" + FOR a = 1 TO 8 + LINE (a * 16, 1)-(a * 16 + 8, 9), bit(a), BF + NEXT a END SUB -SUB send +SUB transmit -b = 0 -FOR a = 1 TO 8 -b = b * 2 -b = b + bit(a) -NEXT a + ' Calculate the byte to be sent based on the status of each pin + outputByte = 0 + FOR a = 1 TO 8 + outputByte = outputByte * 2 + outputByte = outputByte + bit(a) + NEXT a -OUT prt, b + OUT printerPort, outputByte END SUB - diff --git a/Networking/read.bas b/Networking/read.bas deleted file mode 100755 index bcfa739..0000000 --- a/Networking/read.bas +++ /dev/null @@ -1,38 +0,0 @@ -' Monitor LPT pin state -' made by Svjatoslav Agejenko -' in 2002 -' H-Page: svjatoslav.eu -' E-Mail: svjatoslav@svjatoslav.eu - - -' Monitors LPT1 pins 14, 16, 17 and some others. - - -DECLARE SUB display () -DIM SHARED frm -SCREEN 13 - - -OUT &H37A, 0 - -1 -display - -GOTO 1 - -SUB display - -a = INP(&H37A) -b = 128 -LOCATE 5, 1 -PRINT a - -FOR c = 1 TO 8 -IF a >= b THEN a = a - b: d = 3 ELSE d = 1 -b = b / 2 -CIRCLE (c * 10, 10), 4, d -PAINT (c * 10, 10), d -NEXT c - -END SUB - diff --git a/System/CMOS string/getenv.asm b/System/CMOS string/getenv.asm deleted file mode 100644 index a2a5933..0000000 --- a/System/CMOS string/getenv.asm +++ /dev/null @@ -1,56 +0,0 @@ -; by: Svjatoslav Agejenko -; homepage: svjatoslav.eu -; email: svjatoslav@svjatoslav.eu -; on: 2002.10.07 -; compile with FASM ( Flat ASseMbler ) by Tomasz Grysztar - -org 100h - -cmaddr = 53h - - - mov ah, 3ch ; create file - sub cx, cx - mov dx, name - int 21h - mov [hand], ax - - mov al, cmaddr - out 70h, al - in al, 71h - - mov di, eof - sub cx, cx - mov cl, al - mov dl, cmaddr - -l1: inc dl - mov al, dl - out 70h, al - in al, 71h - stosb - loop l1 - - mov cx, di ; write to file - sub cx, line - mov ah, 40h - mov bx, [hand] - mov dx, line - int 21h - - mov ah, 3eh ; close file - mov bx, [hand] - int 21h - - ret - -error: mov ah, 9 - mov dx, err - int 21h - ret - -name db 'setenv.bat', 0 -hand dw 0 -err db 'error occured$' -line db 'SET CMOSE=' -eof: diff --git a/System/CMOS string/getenv.com b/System/CMOS string/getenv.com deleted file mode 100755 index 8cc5102..0000000 Binary files a/System/CMOS string/getenv.com and /dev/null differ diff --git a/System/CMOS string/savecmos.bas b/System/CMOS string/savecmos.bas deleted file mode 100644 index 1eb13ad..0000000 --- a/System/CMOS string/savecmos.bas +++ /dev/null @@ -1,74 +0,0 @@ -DECLARE SUB displayit () -DECLARE SUB newstring () -DECLARE SUB start () -DIM SHARED adr -DIM SHARED maxlen - -start - -2 -PRINT " " -displayit -PRINT " " -PRINT "1 - to enter new string" -PRINT "2 - to quit" -a$ = INPUT$(1) -SELECT CASE a$ - CASE "1" - newstring - CASE "2" - SYSTEM - CASE ELSE - PRINT "unrecognized command" -END SELECT - -GOTO 2 - -SUB displayit -PRINT "Current CMOS contains: "; -OUT &H70, adr -l = INP(&H71) - -IF l > maxlen THEN PRINT "": GOTO 1 -COLOR 0, 15 -FOR a = 1 TO l - OUT &H70, adr + a - PRINT CHR$(INP(&H71)); -NEXT a -COLOR 7, 0 -PRINT " " -1 - -END SUB - -SUB newstring -PRINT " max length |" + SPACE$(maxlen) + "|" -INPUT "Enter new string:", a$ -IF LEN(a$) > maxlen THEN PRINT "too long, max"; maxlen: GOTO 3 - -OUT &H70, adr -OUT &H71, LEN(a$) - -FOR b = 1 TO LEN(a$) - c = ASC(RIGHT$(LEFT$(a$, b), 1)) - OUT &H70, adr + b - OUT &H71, c -NEXT b - -3 -END SUB - -SUB start -adr = 83 -maxlen = 8 - -CLS -PRINT "Svjatoslav Agejenko" -PRINT "svjatoslav@svjatoslav.eu" -PRINT "2002.10.07" -PRINT " " -PRINT "Utility to store max"; maxlen; "character long string in CMOS memory." -PRINT "beginning CMOS address: 0x"; HEX$(adr) - -END SUB -