Here the QB4.5 equivalent of the QB64 code. (https://staging.qb64phoenix.com/showthre...6#pid17636)
This code is faster in DOS. Not in QB64.
In the DOS BOX is this code very fast.
Because the segment is not part of the native operating system in Windows 10 / 11.
Under Windows 10 / 11 is the QB64 code faster
Both examples are intended to show how characters and colors can be displayed at a specific position. And the interaction with the table itself should also be demonstrated in this way.
Both examples are intended for practice purposes.
And not to say that it already exists.
This code is faster in DOS. Not in QB64.
In the DOS BOX is this code very fast.
Because the segment is not part of the native operating system in Windows 10 / 11.
Under Windows 10 / 11 is the QB64 code faster
Both examples are intended to show how characters and colors can be displayed at a specific position. And the interaction with the table itself should also be demonstrated in this way.
Both examples are intended for practice purposes.
And not to say that it already exists.
Code: (Select All)
' Segment B800 is for text memory
' 1 Byte Char + 1 Byte Color (4 Bit Back- and 4 Bit Foreground)
DEF SEG = &HB800
' Screen Info for Screen 0
' max line = 25
' max length = 80
' max colors = 16
' Screen Buffer = 25 * 80 = 2000
' + with colors = 2000 * 2 = 4000
DIM screenchar(1999) AS INTEGER
DIM screencol(1999) AS INTEGER
' dimension variables
DIM winx AS INTEGER
DIM winy AS INTEGER
DIM x AS INTEGER
DIM y AS INTEGER
DIM posi AS INTEGER
DIM keyin AS STRING
' Create window area with colors
winx = 14
winy = 4
FOR y = winy + 0 TO winy + 16
FOR x = winx + 0 TO winx + 16 * 3
screenchar(y * 80 + x) = &H20
screencol(y * 80 + x) = &H70
NEXT x
NEXT y
' Create table info
FOR i = 0 TO 15
screenchar(winy * 80 + winx + (i * 3) + 2) = &H30
screenchar(winy * 80 + winx + (i * 3) + 3) = ASC(HEX$(i))
screencol(winy * 80 + winx + (i * 3) + 2) = &H74
screencol(winy * 80 + winx + (i * 3) + 3) = &H74
screenchar((winy + i + 1) * 80 + winx + 1) = &H30
screenchar((winy + i + 1) * 80 + winx) = ASC(HEX$(i))
screencol((winy + i + 1) * 80 + winx + 0) = &H74
screencol((winy + i + 1) * 80 + winx + 1) = &H74
NEXT i
' Create ASCII characters
winx = winx + 1
winy = winy + 1
x = 0
y = winy
FOR i = 0 TO 255
screenchar(y * 80 + (winx + (x * 3 + 2))) = i
screencol(y * 80 + (winx + (x * 3 + 2))) = &H70
x = x + 1
IF x = 16 THEN
x = 0
y = y + 1
END IF
NEXT i
' Draw all ASCII Chars in the table
FOR i = 0 TO 3999 STEP 2
POKE i + 0, screenchar(i \ 2)
POKE i + 1, screencol(i \ 2)
NEXT i
' Start of selectet character
posi = (winy + sely) * 80 + (winx + selx * 3)
screencol(posi) = &H27
POKE ((posi + 2) * 2) + 1, screencol(posi)
DO
' Color change by new position
IF posi <> ((winy + sely) * 80 + (winx + selx * 3)) THEN
' Old position reset
screencol(posi) = &H70
POKE ((posi + 2) * 2) + 1, screencol(posi)
' New position set
posi = (winy + sely) * 80 + (winx + selx * 3)
screencol(posi) = &H27
POKE ((posi + 2) * 2) + 1, screencol(posi)
END IF
' Output of decimal and hex value of current char
COLOR 0, 7
LOCATE winy + 17, winx: PRINT SPACE$(25)
LOCATE winy + 17, winx: PRINT "ASCII: DEC(" + LTRIM$(STR$(sely * 16 + selx)) + ") HEX(" + HEX$(sely * 16 + selx) + ")"
' Key Input
DO
keyin = INKEY$
LOOP WHILE keyin = ""
' Arrow keys to select the current char
IF keyin = CHR$(0) + CHR$(77) THEN IF selx >= 15 THEN selx = 0 ELSE selx = selx + 1
IF keyin = CHR$(0) + CHR$(75) THEN IF selx <= 0 THEN selx = 15 ELSE selx = selx - 1
IF keyin = CHR$(0) + CHR$(80) THEN IF sely >= 15 THEN sely = 0 ELSE sely = sely + 1
IF keyin = CHR$(0) + CHR$(72) THEN IF sely <= 0 THEN sely = 15 ELSE sely = sely - 1
' ESC to end the program
LOOP WHILE keyin <> CHR$(27)