Qbasicnews.com
April 09, 2020, 06:32:07 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Black box around text  (Read 5166 times)
andy
Senior Member
**
Posts: 175



WWW
« on: October 27, 2003, 01:03:19 PM »

When using the code:

Code:
screen 13
cls
line(20,0)-(180,320),26,bf
locate 10,10
? "Hello"


There is a small black box around the text.

I could only figuer out one method to avoid this.

Code:
for y = 20 to 180
for x = 1 to 360
if point(x,y) = 15 then pset(x,y),26
next:next


This works, but it is slow and anoying. Does anyone know any better methods.
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #1 on: October 27, 2003, 01:52:17 PM »

Without using libraries, your best bet is to have a sub that use LINEs to draw sequences of letters (words). Otherwise, use the QBASIC graphics stuff. I'd advise against it though. It's extremely messy stuff.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #2 on: October 27, 2003, 02:45:56 PM »

It's not that hard. Tongue

Code:
' Print text without the black box in screen 13
' by Plasma

DEFINT A-Z
DECLARE SUB ColorPrint (Row, Column, Text$, TextColor)

' Example:
SCREEN 13
CLS
LINE (20, 0)-(180, 320), 26, BF
ColorPrint 10, 10, "Hello", 15

SUB ColorPrint (Row, Column, Text$, TextColor)

  StartX = (Column - 1) * 8
  StartY = (Row - 1) * 8

  FOR x = 1 TO LEN(Text$)
    Char = ASC(MID$(Text$, x, 1))
    FOR y = &HFA6E + Char * 8 TO &HFA6E + 7 + Char * 8
      DEF SEG = &HF000
      Bits = PEEK(y)
      DEF SEG = &HA000
      Offset& = StartY * 320& + StartX
      IF Bits AND 128 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      IF Bits AND 64 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      IF Bits AND 32 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      IF Bits AND 16 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      IF Bits AND 8 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      IF Bits AND 4 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      IF Bits AND 2 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      IF Bits AND 1 THEN POKE Offset&, TextColor
      Offset& = Offset& + 1
      StartY = StartY + 1
    NEXT
    StartX = StartX + 8
    StartY = (Row - 1) * 8
  NEXT
  DEF SEG

END SUB
Logged
Mango
Wandering Guru
***
Posts: 360



« Reply #3 on: October 27, 2003, 02:50:48 PM »

Quote from: "andy"
This works, but it is slow and anoying. Does anyone know any better methods.


I don't usually do things like this, so don't have example code.  However, it should be pretty straightforward to write your text to screen, use the graphics 'get'  function to put the text in memory (as graphics, not text), then use the graphics 'put' function to put the text to screen *using the OR action mode*.

Here...I just tested it...works fine
Code:
SCREEN 13

s$ = "Hello"   ' Here's our string

'Lets find out how much graphics memory will be needed to hold it
bytesperpixel% = 1
charwidth% = 8    ' 320 pixels across / 40 characters across
charheight% = 10 ' 240 pixles vertical/ 24 characters vertical
numcharacters% = LEN(s$)
pixles% = charwidth% * charheight% * numcharacters%
bytesneeded% = pixles% * bytesperpixel%
intsneeded% = bytesneeded%

DIM myword(1 TO intsneeded%) AS INTEGER   'used to hold text
  ' OK...we are ready to put text in memory

cls
PRINT s$
GET (0, 0)-(numcharacters% * charwidth%, charheight%), myword
CLS

  'ok...text is in memory.  Now...we draw stuff on screen
LINE (0, 0)-(319, 239), 25, BF
   ' and now we can print our text on top of what's drawn on screen with no black box
PUT (50, 50), myword, OR
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #4 on: October 27, 2003, 02:56:30 PM »

Plasma, you are the peek and poke MASTER!!
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #5 on: October 27, 2003, 03:11:10 PM »

Or you could of course use a custom font. They look nicer than the original QB fonts....
Logged
Mango
Wandering Guru
***
Posts: 360



« Reply #6 on: October 27, 2003, 03:41:55 PM »

Quote from: "dark_prevail"
Or you could of course use a custom font. They look nicer than the original QB fonts....


Could someone post or point me to a simple (stripped) example that creates a custom font and uses it to print text to screen, with no other code distractions?  TIA
Logged
Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #7 on: October 27, 2003, 03:49:30 PM »

Just change the segment and offset of my example to get the font data from somewhere else...the characters are stored as bit images, with one byte per line, 8 bytes per character.
Logged
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #8 on: October 27, 2003, 04:25:08 PM »

Just use a lib like Future.Library =P.
Logged
pr0gger
I hold this place together
*****
Posts: 775


« Reply #9 on: October 27, 2003, 06:41:59 PM »

:king:  <--- Plasma
Logged

size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Neo
Na_th_an
*****
Posts: 2150



« Reply #10 on: October 28, 2003, 06:42:48 AM »

Plasma the king... Wink lol
That's what you get when you have a lot of experience with it Smiley
Memory location &HF000 and &HA000 ....
Logged
Neo
Na_th_an
*****
Posts: 2150



« Reply #11 on: October 28, 2003, 06:44:50 AM »

EDIT: sorry for double clicking the submit-button Smiley
Logged
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #12 on: October 28, 2003, 03:26:14 PM »

Quote from: "Neo"
Plasma the king... Wink lol
That's what you get when you have a lot of experience with it Smiley
Memory location &HF000 and &HA000 .... which are the location of the ROM Bios and the 13h VGA Screen Buffer.


I have one word for you - EDIT! and delete your previous post  Smiley .
Logged
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #13 on: October 29, 2003, 12:30:50 AM »

BAD TBBQ: by posting that message you made it impossible for Neo to delete his message!! Tongue
Logged

barok
Na_th_an
*****
Posts: 1727


How about a tasty lead sandwich?


« Reply #14 on: October 29, 2003, 02:18:32 AM »

isn't it something like &hf800?  i think there's an 8 in there....
Logged

Jumping Jahoolipers!
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!