COLOR for screen 13

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
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

COLOR for screen 13

Post by Sinuvoid » Mon Dec 24, 2007 9:59 am

I need to change the backround color of the text, but QB doesn't let you do this in screen 13. is there a way around this?

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Mon Dec 24, 2007 1:47 pm

Use your own bitmapped font routine, or use a library which already does it. There is no other way.

User avatar
burger2227
Veteran
Posts: 2429
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Mon Dec 24, 2007 2:01 pm

Here is an Interrupt SUB routine to print text with any color background:

Code: Select all

'$INCLUDE: 'QB.BI'
DIM SHARED Registers AS RegTypeX


SUB ColorPrint (text$, row%, col%, fc%, bc%) STATIC

    c$ = STRING$(LEN(text$), 219)   'string of solid BG characters

    Registers.ax = &H1300           'video service 13h, subfunction 0
    Registers.bx = bc%              'BH = page (0), BL = Background color
    Registers.cx = LEN(text$)       'CX = string length
    Registers.dx = 256 * (row% - 1) + (col% - 1)  'DH = row, DL = column
    Registers.es = VARSEG(c$)       'ES = string data segment
    Registers.bp = SADD(c$)         'BP = string address
    CALL InterruptX(&H10, Registers, Registers)   'call the BIOS to print it

    Registers.bx = (fc% XOR bc%) + &H80 'BL = color, +&H80 means use XOR
    Registers.es = VARSEG(text$)    'ES = string data segment
    Registers.bp = SADD(text$)      'BP is the string address
    CALL InterruptX(&H10, Registers, Registers)   'call the BIOS

END SUB
The row% and col% are normal text rows and columns. Text$ is your string of text, fc% = forecolor and bc% = backcolor.

You will need to run the QB45 library (QB.EXE /L) and '$Include: 'QB.BI'.
Also DIM SHARED Registers AS REGTYPEX at the beginning of the program.

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

Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid » Mon Dec 24, 2007 2:47 pm

I think Ill go with Nod's for learning experience :P

User avatar
burger2227
Veteran
Posts: 2429
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Tue Dec 25, 2007 2:31 am

You and Nod have a better chance of getting married than either one of you can learn how to code! LEE , LEE, LEE?

Do you know how to do anything on your own? I could help, but I am not going to encourage the idiot and your constant posts! However, I do like Penn........... and Teller. Great avitar! I also proved that there IS another way!

Merry Christmas .........ho .......ho ......ho!

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

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Tue Dec 25, 2007 3:04 am

What you posted would be considered a library, especially since it requires QB's utility library.

By the way, I'm already married. This is my wife.

User avatar
burger2227
Veteran
Posts: 2429
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

STFU, Interrupt is a valid function built into the library

Post by burger2227 » Tue Dec 25, 2007 4:04 am

There is absolutely no reason to have to create a new library when QB45 has it there for the asking. Get real!

And I am your father, N! LOL

LEE are you really running a contest or begging for help? I would, but I think you are a figment of somebody's imagination and I already tried that road.

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

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Tue Dec 25, 2007 4:25 am

I never stated creating a new library object. In this context, the word "library" refers to a collection of general purpose functions. Or, in this case, a single function. Of course, if you want to argue semantics, feel free to argue with yourself.

Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid » Tue Dec 25, 2007 8:27 am

Hm, you guys must really hate each other xD

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Tue Dec 25, 2007 12:57 pm

I don't hate him. Hating him would be the same as hating the last thing I flushed down the toilet.

User avatar
burger2227
Veteran
Posts: 2429
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Tue Dec 25, 2007 5:25 pm

I don't hate him either! But he does smell like something I hate even after I flush the toilet!

Admit it NOD! You made LEE up, didn't you? I saved that GIF, gotta love it!
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

Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid » Tue Dec 25, 2007 5:28 pm

No, Lee is myself...?

User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth » Tue Dec 25, 2007 5:30 pm

Ted, what's it between you and Nod? It's like you two have a contest about who's better... But you're both good at what you do...
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.

User avatar
burger2227
Veteran
Posts: 2429
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Yep we both are good at insults!

Post by burger2227 » Tue Dec 25, 2007 5:43 pm

It seems to be going the other way! We are in a contest to see who is Worser LOL.

User avatar
Kiyotewolf
Veteran
Posts: 96
Joined: Tue Apr 01, 2008 11:38 pm

colored text

Post by Kiyotewolf » Mon Apr 07, 2008 1:01 am

I have solved this problem awhile ago since doing an ANSI thingy in EGA..

Assuming you are using SCREEN 13,.. i'll go with that..


make an 8x8 box of the color 255 using LINE

get it..

xor it over your text that was color'ed in color 255 as well

now, your text background has shifted from the background to the foreground.

get the data

line your background color in an 8x8 box

put the data using AND over the colored box

get the data

draw the character normal using color 255

get it

line your foreground as an 8x8 cube

put with AND over the colored box

get it..

put your background colored piece down first, then put using OR your foreground colored text over it to make them finish up..

people flame each other for posting code.. so that's as far as i'm going to explain it..

flaming is sad.. a sad sad waste of time..

Kiyote!
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.

Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph » Mon Apr 07, 2008 7:23 pm

Lee:

If you only want the text background to match the SCREEN background, here is another way. Since it involves GETting and PUTting, first of all, let us know if you understand how to use those two graphics statements. Assuming you do, here's how:
1. Print the string.
2. DIMension an array to (L*8,8 ), where L is the LENgth of the string, and the number of pixels for each character are 8, both horizontally and vertically.
3. GET the string into the array.
4. Blot out the above string with a LINE statement ending in BF .
5. PUT the string where desired.

In the above, remember that each character of text has a height of 8 pixels, and a width of 7 pixels. SCREEN 13 is 320 pixels (or 320/8 = 40 characters) wide, and 200 pixels (or 200/8 = 25 lines) high.
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish

User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat » Mon Apr 07, 2008 8:20 pm

Seb McClouth wrote:Ted, what's it between you and Nod? It's like you two have a contest about who's better... But you're both good at what you do...
I win. 8)
There, it's settled.

As for the topic, I would guess using PUT for the bitmaps.

Or if you're really bored, pset every pixel. :lol:
For any grievances posted above, I blame whoever is in charge . . .

Post Reply