BITS and BYTES

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
rishu
Newbie
Posts: 7
Joined: Thu Jul 17, 2008 4:48 am
Location: indyeah

BITS and BYTES

Post by rishu »

in qb help file look for paint command. under tile$ folowing is written "8 bits wide and 64 bytes long". How the concept of bits and bytes apply here.
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

I guess the logic of memory chips apply here.... a memory chip is say 16 bits wide, and 2Mbytes in size... once "cell" of information is 16 bits... you have 1M information "cells" in the chip.
Mida sa loed ? Nagunii aru ei saa :P
rishu
Newbie
Posts: 7
Joined: Thu Jul 17, 2008 4:48 am
Location: indyeah

Post by rishu »

n = 1
DO
CLS
SCREEN 12
CIRCLE (160, 100), 40, 1
PAINT (160, 100), CHR$(n), 1
PRINT n
n = n + 1
SLEEP 2
LOOP UNTIL INKEY$ = CHR$(27) 'press esc to end
END



i am posting answer of my own question. :!:
let us consider screen 12. it 's 640x480
now the whole screen is divided into 80 parts across. Each part is again subdivided into 8 parts.

if we enter chr$(48). its binary form is 110000. where there is 1 the computer will paint a vertical line in each subparts upto ur boundry color that u specified.
whre there is 0, it'll remain black.
If there are consecutive two 1's it'll be a thicker line. if 3 then more thicker line.

if chr$(255) then the whole stuff will be filled bcuz its binary form is 11111111.

I am currently researching to find the color pattern it follows. eg. if we use only one CHR$ it prints onscreen in blue color and if we use CHR$(something)+CHR$(something), it uses a different color. i have got a lot forward may be after some hours i'll get it.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Here is another demo of how string characters are used in PAINT:

Code: Select all

SCREEN 13
PAINT (160, 100), CHR$(1) + CHR$(2), 15
PRINT "The pattern"
DO: LOOP WHILE INKEY$ = ""
CLS
LINE (0, 50)-(319, 50), 1
PRINT "A line"
DO: LOOP WHILE INKEY$ = ""
PAINT (160, 100), CHR$(1) + CHR$(2), 15
PRINT "The pattern is blocked by the line even"
PRINT "though the border color is white because"
PRINT "the destination pixel was already the"
PRINT "color the patternwould have set it to!"
DO: LOOP WHILE INKEY$ = ""
CLS
LINE (0, 50)-(319, 50), 1
PRINT "The same line"
DO: LOOP WHILE INKEY$ = ""
PAINT (160, 100), CHR$(1) + CHR$(2), 15, CHR$(1)
PRINT "The pattern was able to paint over the"
PRINT "blue line and continue because a"
PRINT "background string was specified!"
Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

burger77:
Nice demonsstration!

I went through SCREEN modes 1, 2, and 7 through 13. I observed horizontal lines only for SCREEN mode 13. And, with the suitable change in line from horizontal to vertical, isaw blocking only in modes 2 and 13. By the way, the patterens change, according to the SCREN mode used!
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
Post Reply