Qbasicnews.com

Full Version: Smaller text for SCREEN 13 - or any other valid screen!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Regarding a post that, I beleive, appeared in this forum, requesting a way of writing smaller text than normally available in SCREEN 13 - or any other valid screen - , I have finished writing a QuickBASIC program that writes text using 5 points high by 5 points wide, somewhat smaller than the normal 7x6 points.

EDITED 05-Mar-2006, 10:19 CT: Did some cleaning up. Now, the QuickBASIC editor reports it as having 512 lines of code, including DATA tables, empty lines and remarks. The text file shows 9,512 bytes in a DOS directory, and it is reported as 10KB in Windows.

I do think it is too large to post here, unless I am informed to the contrary.

However, if someone is interested, send me a PM, with your email address, and I will attach the program's text file to my reply.

If someone wants me to post it someplace on the Internet, I will gladly send him my program, and let him do the posting, as I am all thumbs in that respect.

Anonymous

[deleted]
I read chaOs's posting as a GO for me to post my code, so, I will. Mind, my solution only provides for upper-case letters, a comma, a period (dot), and a space, at this time. And, in all fairness, I think that using the DRAW statement might be much more code-size efficient. Anyway, here is my code:

Code:
'LETTERS, Ralph A. Esquivel, 03-Mar-2006, draws letters
CLS
SCREEN 13


'5x5 letters A-H sprites, with space to the right and to the bottom
DIM LA((5 * 5 + 1) / 2 + 2)
DIM LB((5 * 5 + 1) / 2 + 2)
DIM LC((5 * 5 + 1) / 2 + 2)
DIM LD((5 * 5 + 1) / 2 + 2)
DIM LE((5 * 5 + 1) / 2 + 2)
DIM LF((5 * 5 + 1) / 2 + 2)
DIM LG((5 * 5 + 1) / 2 + 2)
DIM LH((5 * 5 + 1) / 2 + 2)
DIM LI((5 * 5 + 1) / 2 + 2)
DIM LJ((5 * 5 + 1) / 2 + 2)
DIM LK((5 * 5 + 1) / 2 + 2)
DIM LL((5 * 5 + 1) / 2 + 2)
DIM LM((5 * 5 + 1) / 2 + 2)
DIM LN((5 * 5 + 1) / 2 + 2)
DIM LO((5 * 5 + 1) / 2 + 2)
DIM LP((5 * 5 + 1) / 2 + 2)
DIM LQ((5 * 5 + 1) / 2 + 2)
DIM LR((5 * 5 + 1) / 2 + 2)
DIM LS((5 * 5 + 1) / 2 + 2)
DIM LT((5 * 5 + 1) / 2 + 2)
DIM LU((5 * 5 + 1) / 2 + 2)
DIM LV((5 * 5 + 1) / 2 + 2)
DIM LW((5 * 5 + 1) / 2 + 2)
DIM LX((5 * 5 + 1) / 2 + 2)
DIM LY((5 * 5 + 1) / 2 + 2)
DIM LZ((5 * 5 + 1) / 2 + 2)

DIM LSpace((5 * 5 + 1) / 2 + 2) 'space
DIM LDot((5 * 5 + 1) / 2 + 2)   'period
DIM LComma((5 * 5 + 1) / 2 + 2) 'comma



'capture a piece of the background for cleaning a section later on
DIM CL((5 * 5 + 1) / 2 + 2) 'CL is the CLeaning sprite

GET (1, 1)-(5, 5), CL

'DRAW and GET letters A-Z & Space, Dot, Comma
GOSUB DrawLetters


'enter word to print, and print it
'''following is a sample string:
WordIs$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ,."

'location desired for string
X = 1: Y = 0
GOSUB PrintWord:
LOCATE 4
PRINT WordIs$

WHILE INKEY$ = "": WEND
END



'=================
'Subroutines:

DrawLetters:
  
  RESTORE A:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LA
  PUT (1, 1), CL, PSET

  RESTORE B:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LB
  PUT (1, 1), CL, PSET

  RESTORE C:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LC
  PUT (1, 1), CL, PSET

  RESTORE D:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LD
  PUT (1, 1), CL, PSET

  RESTORE E:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LE
  PUT (1, 1), CL, PSET

  RESTORE F:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LF
  PUT (1, 1), CL, PSET

  RESTORE G:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LG
  PUT (1, 1), CL, PSET

  RESTORE H:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LH
  PUT (1, 1), CL, PSET

  RESTORE I:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LI
  PUT (1, 1), CL, PSET

  RESTORE J:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LJ
  PUT (1, 1), CL, PSET

  RESTORE K:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LK
  PUT (1, 1), CL, PSET

  RESTORE L:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LL
  PUT (1, 1), CL, PSET

  RESTORE M:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LM
  PUT (1, 1), CL, PSET

  RESTORE N:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LN
  PUT (1, 1), CL, PSET

  RESTORE O:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LO
  PUT (1, 1), CL, PSET

  RESTORE P:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LP
   PUT (1, 1), CL, PSET

  RESTORE Q:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LQ
  PUT (1, 1), CL, PSET

  RESTORE R:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LR
  PUT (1, 1), CL, PSET

  RESTORE S:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LS
  PUT (1, 1), CL, PSET

  RESTORE T:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LT
  PUT (1, 1), CL, PSET

  RESTORE U:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LU
  PUT (1, 1), CL, PSET

  RESTORE V:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LV
  PUT (1, 1), CL, PSET

  RESTORE W:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LW
  PUT (1, 1), CL, PSET

  RESTORE X:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LX
   PUT (1, 1), CL, PSET

  RESTORE Y:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LY
  PUT (1, 1), CL, PSET

  RESTORE Z:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LZ
  PUT (1, 1), CL, PSET

  RESTORE Space:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LSpace
  PUT (1, 1), CL, PSET

  RESTORE Dot:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LDot
  PUT (1, 1), CL, PSET

  RESTORE Comma:
  GOSUB LETT:
  GET (1, 1)-(5, 5), LComma
  PUT (1, 1), CL, PSET

RETURN



LETT:
  LOCATE 5
  FOR Y = 1 TO 5
    FOR X = 1 TO 5
      READ C
      PSET (X, Y), C
    NEXT X
  NEXT Y
RETURN



PrintWord:    
  AA = 6
  FOR I = 0 TO LEN(WordIs$) - 1
    A$ = MID$(WordIs$, I + 1, 1)
    IF A$ = "A" THEN
      PUT (X + I * AA - 1, Y), LA, PSET
    ELSEIF A$ = "B" THEN
      PUT (X + I * AA - 1, Y), LB, PSET
    ELSEIF A$ = "C" THEN
      PUT (X + I * AA - 1, Y), LC, PSET
    ELSEIF A$ = "D" THEN
      PUT (X + I * AA - 1, Y), LD, PSET
    ELSEIF A$ = "E" THEN
      PUT (X + I * AA - 1, Y), LE, PSET
    ELSEIF A$ = "F" THEN
      PUT (X + I * AA - 1, Y), LF, PSET
    ELSEIF A$ = "G" THEN
      PUT (X + I * AA - 1, Y), LG, PSET
    ELSEIF A$ = "H" THEN
      PUT (X + I * AA - 1, Y), LH, PSET
    ELSEIF A$ = "I" THEN
      PUT (X + I * AA - 1, Y), LI, PSET
    ELSEIF A$ = "J" THEN
      PUT (X + I * AA - 1, Y), LJ, PSET
    ELSEIF A$ = "K" THEN
      PUT (X + I * AA - 1, Y), LK, PSET
    ELSEIF A$ = "L" THEN
      PUT (X + I * AA - 1, Y), LL, PSET
    ELSEIF A$ = "M" THEN
      PUT (X + I * AA - 1, Y), LM, PSET
    ELSEIF A$ = "N" THEN
      PUT (X + I * AA - 1, Y), LN, PSET
    ELSEIF A$ = "O" THEN
      PUT (X + I * AA - 1, Y), LO, PSET
    ELSEIF A$ = "P" THEN
      PUT (X + I * AA - 1, Y), LP, PSET
    ELSEIF A$ = "Q" THEN
      PUT (X + I * AA - 1, Y), LQ, PSET
    ELSEIF A$ = "R" THEN
      PUT (X + I * AA - 1, Y), LR, PSET
    ELSEIF A$ = "S" THEN
      PUT (X + I * AA - 1, Y), LS, PSET
    ELSEIF A$ = "T" THEN
      PUT (X + I * AA - 1, Y), LT, PSET
    ELSEIF A$ = "U" THEN
      PUT (X + I * AA - 1, Y), LU, PSET
    ELSEIF A$ = "V" THEN
      PUT (X + I * AA - 1, Y), LV, PSET
    ELSEIF A$ = "W" THEN
      PUT (X + I * AA - 1, Y), LW, PSET
    ELSEIF A$ = "X" THEN
      PUT (X + I * AA - 1, Y), LX, PSET
    ELSEIF A$ = "Y" THEN
      PUT (X + I * AA - 1, Y), LY, PSET
    ELSEIF A$ = "Z" THEN
      PUT (X + I * AA - 1, Y), LZ, PSET
    ELSEIF A$ = " " THEN
      PUT (X + I * AA - 1, Y), LSpace, PSET
    ELSEIF A$ = "." THEN
      PUT (X + I * AA - 1, Y), LDot, PSET
    ELSEIF A$ = "," THEN
      PUT (X + I * AA - 1, Y), LComma, PSET
    END IF
      PUT (X + I * AA - 1 + 5, Y), LSpace, PSET
  NEXT I
RETURN



'====================
'size 5X5 letters A-H, Space, Dot, Comma

A:
DATA 15,15,15,15,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15

B:
DATA 15,15,15,15,00
DATA 15,00,00,00,15
DATA 15,15,15,15,00
DATA 15,00,00,00,15
DATA 15,15,15,15,00

C:
DATA 15,15,15,15,00
DATA 15,00,00,00,00
DATA 15,00,00,00,00
DATA 15,00,00,00,00
DATA 15,15,15,15,00
          
D:
DATA 15,15,15,15,00
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,15,15,15,00

E:
DATA 15,15,15,15,15
DATA 15,00,00,00,00
DATA 15,15,15,15,00
DATA 15,00,00,00,00
DATA 15,15,15,15,15

F:
DATA 15,15,15,15,15
DATA 15,00,00,00,00
DATA 15,15,15,15,00
DATA 15,00,00,00,00
DATA 15,00,00,00,00

G:
DATA 15,15,15,15,15
DATA 15,00,00,00,00
DATA 15,00,00,15,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15

H:
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15

I:
DATA 00,15,15,15,00
DATA 00,00,15,00,00
DATA 00,00,15,00,00
DATA 00,00,15,00,00
DATA 00,15,15,15,00

J:
DATA 00,00,00,00,15
DATA 00,00,00,00,15
DATA 15,15,00,00,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15

K:
DATA 15,00,00,00,15
DATA 15,00,15,15,00
DATA 15,15,00,00,00
DATA 15,00,15,15,00
DATA 15,00,00,00,15
          
L:
DATA 15,00,00,00,00
DATA 15,00,00,00,00
DATA 15,00,00,00,00
DATA 15,00,00,00,00
DATA 15,15,15,15,15

M:
DATA 15,00,00,00,15
DATA 15,15,00,15,15
DATA 15,00,15,00,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15

N:
DATA 15,00,00,00,15
DATA 15,15,00,00,15
DATA 15,00,15,00,15
DATA 15,00,00,15,15
DATA 15,00,00,00,15

O:
DATA 15,15,15,15,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15

P:
DATA 15,15,15,15,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15
DATA 15,00,00,00,00
DATA 15,00,00,00,00

Q:
DATA 15,15,15,15,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,00,00,15,15
DATA 15,15,15,15,15

R:
DATA 15,15,15,15,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15
DATA 15,00,15,15,00
DATA 15,00,00,00,15

S:
DATA 15,15,15,15,15
DATA 15,00,00,00,00
DATA 15,15,15,15,15
DATA 00,00,00,00,15
DATA 15,15,15,15,15
          
T:
DATA 15,15,15,15,15
DATA 00,00,15,00,00
DATA 00,00,15,00,00
DATA 00,00,15,00,00
DATA 00,00,15,00,00

U:
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,15,15,15,15

V:
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 00,15,00,15,15
DATA 00,15,00,15,00
DATA 00,00,15,00,00

W:
DATA 15,00,00,00,15
DATA 15,00,00,00,15
DATA 15,00,15,00,15
DATA 15,15,00,15,15
DATA 15,00,00,00,15

X:
DATA 15,00,00,00,15
DATA 00,15,00,15,00
DATA 00,00,15,00,00
DATA 00,15,00,15,00
DATA 15,00,00,00,15

Y:
DATA 15,00,00,00,15
DATA 00,15,00,15,00
DATA 00,00,15,00,00
DATA 00,00,15,00,00
DATA 00,00,15,00,00

Z:
DATA 15,15,15,15,15
DATA 00,00,00,15,00
DATA 00,00,15,00,00
DATA 00,15,00,00,00
DATA 15,15,15,15,15

Space:
DATA 00,00,00,00,00
DATA 00,00,00,00,00
DATA 00,00,00,00,00
DATA 00,00,00,00,00
DATA 00,00,00,00,00
          
Dot:
DATA 00,00,00,00,00
DATA 00,00,00,00,00
DATA 00,00,00,00,00
DATA 00,00,00,00,00
DATA 00,00,15,00,00

Comma:
DATA 00,00,00,00,00
DATA 00,00,00,00,00
DATA 00,00,15,00,00
DATA 00,00,15,00,00
DATA 00,15,00,00,00



RETURN
Code:
'5x4 font for screen 13, by Biskbart. QB version
'
declare SUB PrintC (X%, Y%, Texte$, Couleur%, Segment&, Offset&)
screen 13
dim shared xmax&,ymax&
xmax&=320:ymax&=200
DIM SHARED Police%(0 TO 62)
printc 10,10,"5,4,3,2,1, Hello, world!, ABCDEFGHIJKLMN",15,&ha000,0&
sleep
'
'-----------------------------------------------------------------------
Data.Police:
'Font 5x4 defined by 5 octal digits bottom line (msd) to top line (lsd)
'Implemented Chr 32 to chr 96, only caps
'
'    SP   1   "      #     $     %    &      '    (     )      *    +
DATA 0,08338,00045,24445,32223,21157,15018,00018,08778,10530,02728,01488
'      ,     -     .     /     0     1     2    3     4     5     6
DATA 05120,00448,08192,05268,11114,18740,29351,31143,18926,31183,31695
'      7     8     9     :     ;     <     =     >     ?     @     A
DATA 04775,10922,31215,01040,05136,17492,03640,05393,08615,29695,23535
'      B     C     D     E     F    G      H     I     J     K     L
DATA 15083,29263,15211,29391,04815,31311,23533,09362,11044,23277,29257
'      M     N     O     P     Q    R      S     T     U     V     W
DATA 23421,24573,11114,05103,15215,22511,31183,09367,31597,11117,24429
'      X     Y     Z     [     \    ]    ^
DATA 23213,09389,29351,29263,17553,31015,&o52
'
'------------------------------------------------------------------------
SUB PrintC (X%, Y%, Texte$, Couleur%, Segment&, Offset&)
if police%(1)=0 then
  RESTORE Data.Police
  FOR I% = 0 TO 62: READ Police%(I%): NEXT I%
end if
DEF SEG = Segment&
   P1&=Offset&+ 320&*Y%+x%
   texte$=ucase$(texte$)
   FOR I% = 1 TO LEN(Texte$)
    P2% = police%(ASC(MID$(Texte$, I%, 1)) - 32)
    P&=p1&
    FOR J% = 0 TO 4
     FOR K% = 0 TO 2
      ' A optimiser que diable !!!
      IF &H1 AND P2% THEN POKE p&+ K%, Couleur%
      P2% = P2% \ 2
     NEXT K%
     p&=p&+320
    NEXT J%
    p1&=p1&+4
  NEXT I%
end sub
I guess that a statement I made a short time ago, to the effect that I am not a programmer, is now clearly and loudly proven by Antoni's post, above! :oops: :oops: :oops:

Antoni, I did try to load your posted program, but, when I try to load it in QuickBASIC 4.5, I only get a "Division by zero" message. What do I have to do to correct this?

EDITED: Never mind, I now was able to load and run the program. Very good results visible on screen!

2nd Edit: For a newbie, how does one determing the segment and the offset? Or, are the values used in the PRINTC line always valid? I suppose not, since, if so, they would probalby have been included in the SUB as a given, right?

3RD (and final!) Edit: By the way, it seems that the font width is actually only 3 pixels! Perhaps the "5x4" includes an empty pixel, for spacing the characters? I did not consider spacing in my very long program, only actual height and width used by each character.
Segment is &hA000 and offset is 0 for graphics screen. The arguments are there to be able to print to a buffer, you can use VARSEG and VARPTR in that case.
And yes, the width is in this case the spacing between leftmost points of two consecutive chars. One of the features of this font is each char fits in an integer and you can design chars from the top of your head : if you use octal each pixel line is a figure.

Anonymous

i wouldnt say you aren't a programmer. everyone starts with the basics (no pun intended) and slowly factors in more and more information about structures, looping, etc...

the only way you "aren't a programmeR" is if you give up programming =p
here's mine

Code:
screen 13

string$ = "yoyomama"

dim locx as integer, locy as integer

locx = 0
locy = 0

line(locx, locy)-(locx+len(string$), locy), 15

END
Antoni:

Just a small observation. The first character is SP, a space. The second character should be shown as an !, not as a 1. All else seems to be fine.
Antoni:
Would you please explain how to use
Quote:each char fits in an integer and you can design chars from the top of your head : if you use octal each pixel line is a figure.
to obtain, say, a 0 and an O as 11114? When I drew a 0 as:
010
101
101
101
010
and translated the binary value 010101101101010 into decimal, I got 11114. Does the program then translate 11114 into octal?

Thanks. And, by the way, I found a neat way to translate any of the characters in the program you posted from the drawn character, or sprite, to the decimal number you show, or to an octal number, if that is required. The method can easily be extended to any other size of character or sprite. The only thing is, the numbers obtained in this manner are based on zeros and ones, so only one color per sprite can be assigned by the program.


While it is true tht this is a QuickBASIC forum, my mehtod for this involves an Excel spreadsheet.

I start by highlighting columns A, B and C for the present case, doing a Format, Column, Width, and choosing 5, to give a reasonabl-looking sprite.

In cell A2, I write SPRITE; in cell D2, BINARY; in cell E2, BIN2DEC; in cell F2, DEC2OCT.

In cell D3, I enter =A3&B3&C3, and copy down to D7.

In cell E7, I enter =MID(D7,1,1)*2^2+MID(D7,2,1)*2+MID(D7,3,1)
In cell E6, I enter =MID(D6,1,1)*2^5+MID(D6,2,1)*2^4+MID(D6,3,1)*2^3
In cell E5, I enter =MID(D5,1,1)*2^8+MID(D5,2,1)*2^7+MID(D5,3,1)*2^6
In cell E4, I enter =MID(D4,1,1)*2^11+MID(D4,2,1)*2^10+MID(D4,3,1)*2^9
In cell E3, I enter =MID(D3,1,1)*2^14+MID(D3,2,1)*2^13+MID(D3,3,1)*2^12

In cell F3, if I want octal numbers, I enter, =DEC2OCT(E3), and copy down to F7.

Now, any sprite I enter in the range A3:C7 as 0s and 1s appears in column D as binary numbers, and in column D and E as decimals and octals for the whole binary number represented in the sprite as the range A3:C7, or the range D3Big Grin7.

Using the above is how I saw that the 11114 Antoni shows, for a 0 and for an O, is not an octal, but a decimal. And, the method can easily be expanded for larger sprites!

I can see that this kind of representation for sprites of one color can be a real memory and code saver, for those programmers that do graphics. I wonder if the numeric representation IS used in this manner?

Comments?
Pages: 1 2