r/QuickBasic • u/SupremoZanne • Nov 12 '22
Changing the CGA Palette in QuickBasic
r/QuickBasic • u/SupremoZanne • Nov 12 '22
r/QuickBasic • u/SupremoZanne • Nov 10 '22
A place for members of r/QuickBasic to chat with each other
r/QuickBasic • u/SupremoZanne • Feb 11 '26
'
' SCREEN 0 OCTAL PALETTE INDEX TOOL
'
' use this tool to find combinations of "dark" and "bright"
' color swatches of the 64 possible colors which SCREEN 0 can
' utilize on it's 16 available color slots.
'
' works on QBasic & QB64
'
s$ = CHR$(219)
DIM dd AS INTEGER
WIDTH 80, 25
CLS
PRINT "SCREEN 0 OCTAL PALETTE INDEX TOOL"
COLOR 2
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT s$; s$; s$; s$; s$; s$; s$
PRINT s$; s$; s$; s$; s$; s$; s$
PRINT s$; s$; s$; s$; s$; s$; s$
PRINT s$; s$; s$; s$; s$; s$; s$
COLOR 7
PRINT
PRINT "press UP and DOWN to adjust left OCTAL digit"
PRINT "press LEFT and RIGHT to adjust right OCTAL digit"
PRINT
PRINT "press SPACE to quit"
DO
LOCATE 4, 1
cc$ = LTRIM$(STR$(a)) + LTRIM$(STR$(b))
PALETTE 2, VAL("&o" + cc$)
dd = VAL("&o" + cc$)
PRINT "OCTAL value: "; cc$; " "
PRINT "DECIMAL value: "; dd
PRINT "HEXADECIMAL value: "; HEX$(VAL("&o" + cc$)); " "
k$ = ""
WHILE k$ = ""
k$ = INKEY$
WEND
SELECT CASE k$
CASE CHR$(0) + "H"
a = (a + 1) MOD 8
CASE CHR$(0) + "P"
a = (a - 1)
IF a < 0 THEN a = 7
CASE CHR$(0) + "K"
b = (b - 1)
IF b < 0 THEN b = 7
CASE CHR$(0) + "M"
b = (b + 1) MOD 8
CASE " "
END
END SELECT
LOOPr/QuickBasic • u/SupremoZanne • Dec 30 '25
' Star generator
' made on QuickBasic 4.5
SCREEN 13
DO
FOR y = 0 TO 250
LINE (0, (y + 10) MOD 250)-(319, (y + 10) MOD 250), 0
IF z = 0 THEN
r = INT(RND * 25) + 2
z = INT(RND * 15) + 1
END IF
z = z - 1
FOR x = 1 TO 319
IF x MOD (r + INT(RND * 10)) = 0 AND z = 1 THEN
PSET (x, y + INT(RND * 10)), 15
END IF
NEXT
NEXT
LOOPr/QuickBasic • u/SupremoZanne • Dec 14 '25
'
' ><><><>< RAINBOW SCROLL ><><><><
'
' a scrolling rainbow of SCREEN 13's possible 256 color attributes.
' but because SCREEN 13 has 320 pixels in the X axis, this is why an
' "X marks the spot" in the region between values 256 to 319 where
' a gap between horizontal pixel count, and color attribute availability
' is present. Yup, an old navy of sea captains have found the pirate's
' treasure since X marks the spot. Just thought I'd throw in an Old Navy
' joke since the famous clothes store was a side brand from GAP.
'
' Yup, the spot is on the axis.
'
'
DIM a(8000)
DIM b(100) ' a separate array for a smooth scroll
SCREEN 13
FOR x = 1 TO 319
SELECT CASE x
CASE 0 TO 255
LINE (x, 0)-(x, 199), x
CASE ELSE
FOR y = 0 TO 199 STEP 8
PSET (x, y + ((x MOD 4) * 2)), 15
PSET (x, (y + ((x MOD 4) + 2) * 2)), 10
NEXT
END SELECT
NEXT
LINE (256, 0)-(319, 199), 12
LINE (256, 199)-(319, 9), 12
DO
' scrolling in effect
GET (0, 0)-(0, 199), b 'the leftmost row of Y pixels to be moved in
GET (1, 0)-(319, 75), a' preparation of the GET & PUT.
PUT (0, 0), a, PSET
GET (1, 76)-(319, 150), a ' array A is used yet again for another
PUT (0, 76), a, PSET ' portion of the graphics.
GET (1, 151)-(319, 199), a
PUT (0, 151), a, PSET
PUT (319, 0), b, PSET ' scrolling is seamless thanks to this trick.
' now, on to next frame!
t = TIMER
WHILE t = TIMER ' a way to keep it timed
WEND
LOOP UNTIL LEN(INKEY$)r/QuickBasic • u/SupremoZanne • Dec 12 '25
' SLOPE GAUGE
'
' A QBASIC program which gives a readout of a needle gauge type visual
' for any division problem you enter, you might call them slopes if
' using lingo for graphing coordinates, or you might call it a quotient
' if talking about more generic nouns referring to answers to division
' math problems, or you might call it a ratio if you are looking for
' some relationship between numbers, or a proportion if it's a more
' complicated ratio, or you might also call it a fraction if referring
' to the modulo of a non-integer, and a fraction is technically a division
' problem, in which the decimal equivalent is another type of answer to it.
'
' A simple program to give a visual using a red line similar to the red
' needles seen in analogue gauges albeit in a digital tech demo in QBASIC.
'
' To make the program look like an analogue gauge, some numbers were
' labelled in gray-ish text to give it the "gauge" feel so it isn't just
' some generic canvas for a X/Y linear coordinate graph.
'
'
DIM a AS DOUBLE
DIM b AS DOUBLE
SCREEN 13
PALETTE 1, &H1E2528 ' a more ideal color for the gauge labels.
DO
COLOR 15
LOCATE 7, 1
INPUT a
PRINT "----"
INPUT b
IF b = 0 THEN GOSUB breaker
PRINT
PRINT a / b
COLOR 1 ' the color altered by the PALETTE command
LOCATE 1, 26
PRINT "1.5";
LOCATE 1, 32
PRINT "1.2";
LOCATE 1, 9
PRINT "5";
LOCATE 1, 4
PRINT "10";
LOCATE 1, 1
PRINT "40"
LOCATE 1, 14
PRINT "3";
LOCATE 1, 40
PRINT "1";
LOCATE 7, 38
PRINT "3/4";
LOCATE 13, 38
PRINT "1/2";
LOCATE 19, 38
PRINT "1/4";
LOCATE 1, 20
PRINT "2";
LOCATE 25, 40
PRINT "0";
y2 = 200 - (1 * (a / b))
FOR x = 1 TO 319
y = 200 - ((200 / 320) * (x * (a / b)))
LINE (x, y)-(x, y2), 12
y2 = y
NEXT
WHILE INKEY$ = ""
WEND
CLS
LOOP
breaker:
PRINT "CANNOT DIVIDE BY ZERO"
PRINT
PRINT "QUITTING PROGRAM"
PRINT
PRINT "PRESS ANY KEY TO END"
WHILE INKEY$ = ""
WEND
ENDr/QuickBasic • u/SupremoZanne • Nov 22 '25
' MULTIPLICATION TIMES TABLE
'
' A chart of multiplication answers similar to the kind that
' schools show to kid students who are just learning how to
' multiply although it makes things convenient for graduated
' adults too.
'
' QB compliant code (QuickBASIC, QBasic, and QB64 compatible)
'
SCREEN 0
WIDTH 80, 50 ' 80 x 50 text mode enabled for more items to be included.
CLS
x1 = 1
WHILE x1 < 80
x2 = x2 + 1
FOR y = 1 TO 50
n$ = LTRIM$(STR$(x2 * y))
LOCATE y, x1 + xx
PRINT n$;
NEXT
x1 = x1 + LEN(n$) + 1
WEND
WHILE INKEY$ = ""
WEND
WIDTH 80, 25 'return to normalr/QuickBasic • u/SupremoZanne • Sep 14 '25
I noticed this nearly coincidental timing when running QB 4.5 on DOSBox.
And, here's some code I wrote to get a visual on the quirks of the INKEY$ and INP(96) functions.
'
' visualizer for INKEY$ and INP(96) keyboard readouts
' INKEY$ gives pulse readings.
'
' even lines for inkey$, odd lines for INP(96) or INP(&h60)
' INP(96) gives continuous readings.
'
SCREEN 13 ' 256 color mode is useful for visuals on byte readouts
DO
k$ = RIGHT$(CHR$(0) + INKEY$, 1) 'one byte longer to prevent errors
a = (a + 1) MOD 64000
x = a MOD 320
y = ((a \ 320) MOD 100) * 2 ' alternating between inkey$ and INP(96)
'
PSET (x, y), ASC(k$) 'even lines yield inkey$ readings
PSET (x, y + 1), INP(96) 'odd lines yield keyboard scan codes
'
LOOP I could notice the near-coincidental timing on QB 4.5 in DOSBox, but when I tested it on QB64, the output seemed different.
In case you are wondering what number 224 is all about, well, number 224 is a periodic pulse which occurs about maybe one tenth of a second intervals when some keys are pressed down. Number 224 occurs when some of these keys are pressed:
Now, here's a chart of keyboard keys where they have another variant using 224 pulses on INP(96):
| key type | variant with 224 pulses in INP(96) | variant without pulses |
|---|---|---|
| arrow keys | inverted T | numeric keypad |
| PAGE UP & DOWN, HOME, END, INSERT, & DEL | rectangle above inverted-T arrow keys | numeric keypad |
| CTRL & ALT keys | right | left |
| ENTER key | numeric keypad | regular |
| SLASH key | numeric keypad | regular |
I think the 224 pulses are one explanation to why two variants of a key that's otherwise the same key are treated differently in some programs, even though they share the same INP(96) code otherwise.
As with INKEY$, well, maybe 224 pulses in INP(96) might have something to do with special checkpoints or something, well, either way, it's important to be alert of the quirks of some functions in QBasic.
Over time I learn new things about the quirky behavior of keyboard-related functions in QBasic.
r/QuickBasic • u/SupremoZanne • Dec 15 '24
I noticed this, because I got curious about whether or not the image would be identical in another screen mode, but I guess it's not.
Through experience, I also know how to uses FOR....NEXT loops, and sometimes they might also be useful for loading images from arrays, but I guess it depends on how you encode it.
r/QuickBasic • u/SupremoZanne • Dec 07 '24
the value for the brightest shade of white in SCREEN 13's PALETTE command, on the right side of the comma, is 4144959
if you look at it this way.....
63 + (63 * 256) + (63 * 65536) = 4144959
so, if one is familiar with the PEMDAS in math equations, one shall know this formula for color values in SCREEN 13:
red + (green * 256) + (blue * 65536)
so there's sorta a BASE-64 numbering system with the RGB color values, although we use BASE-10 numbers as text to represent them, although some more savvy people would use HEXADECIMAL.
Just thought I'd share a quick numeric value to use on the right side of the comma of PALETTE, in SCREEN 13
r/QuickBasic • u/SupremoZanne • Nov 17 '24
| Official product | Unofficial name | notes |
|---|---|---|
| BASICA | QuickBasic: Prehistoric ROM Edition | from before the GW-BASIC name was used, and some commands in QuickBasic originated from here. |
| GW-BASIC | QuickBasic: GW Edition | had some improvements over BASICA, by not depending on the ROM of the earliest IBM PCs, and still relied on line numbers rather than a scrolling text editor. |
| QuickBasic | QuickBasic Proper | the QuickBasic we all know, and this is when the QuickBasic name started to be used. |
| Borland Turbo Basic | QuickBasic: Turbo Edition | well, it supported many of the same commands which QB & GW had, and was designed for IBM PC clones/compatibles. |
| QBasic | QuickBasic: Interpreter Edition | Well, you know how nicknames get shortened, sometimes the first letter of the first word can be a shorthand form of the name, and this product didn't compile, and only interpreted. |
| Visual Basic for DOS | QuickBasic: Visual Edition | Well, it tried to offer a GUI-like interface in TEXT MODE, and supported some QB commands. |
| QB64 | QuickBasic: 64-bit Edition | is it any wonder that QB stands for "Quick Basic", and the 64 implies being a 64-bit version. |
| QBjs | QuickBasic: Javascript Edition | made to be a web browser app. |
r/QuickBasic • u/SupremoZanne • Jul 14 '24
'
' here you see some random space dots, using lots of
' math, with a bit of modulo, and division, and some
' value-to-string conversion, and etc. for
' formation of.
'
' compatible with QuickBasic 4.5, Qasic 1.1, and QB64.
'
SCREEN 13
FOR y = 1 TO 210
b# = (y / 111771)
a# = INT((b# - INT(b#)) * (10 ^ 16))
a$ = STR$(a#)
a$ = RIGHT$(a$, LEN(a$) - 8)
'PRINT a$
d = 1
FOR x = 1 TO LEN(a$)
IF MID$(a$, x, 1) = "." THEN d = 0
xx = x * 42
o = VAL(MID$(a$, x, 1)) * (6 + (y * .7))
o2 = 0
IF y / 2 = INT(y / 2) THEN o2 = (10 + ((x MOD y) * 7))
hp = (xx + o) + (x MOD ((y / 2) + 1)) + o2
IF d THEN PSET (hp - 100, (y + ((x + 2) MOD ((y / 3) + 20))) - 20)
NEXT
t = TIMER
WHILE t = TIMER
WEND
NEXT
WHILE INKEY$ = ""
WEND