QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: TempodiBasic on November 11, 2019, 10:05:11 am

Title: [FIXED] Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 11, 2019, 10:05:11 am
Hi guys
try to run this example (n°3 in the wiki on PAINT I get nothing ....
who can say me why?
Thans for attention and answers

Code: QB64: [Select]
  1. DIM Row$(1 TO 8)
  2.  
  3.    'make red-brick wall
  4.     Row$(1) = CHR$(&H0) + CHR$(&H0) + CHR$(&HFE) + CHR$(&HFE)
  5.     Row$(2) = Row$(1)
  6.     Row$(3) = Row$(1)
  7.     Row$(4) = CHR$(&H0) + CHR$(&H0) + CHR$(&H0) + CHR$(&H0)
  8.     Row$(5) = CHR$(&H0) + CHR$(&H0) + CHR$(&HEF) + CHR$(&HEF)
  9.     Row$(6) = Row$(5)
  10.     Row$(7) = Row$(5)
  11.     Row$(8) = Row$(4)
  12.     Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8)
  13.  
  14.     LINE (59, 124)-(581, 336), 14, B 'yellow box border to paint inside
  15.     PAINT (320, 240), Tile$, 14 'paints brick tiles within yellow border
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 11, 2019, 10:17:58 am
Hi. Bad News. in help for PAINT is:
fillColor could be a string made up of a sequence of CHR$ values, each representing a tiling pattern to fill the shape.
While this is not implemented in QB64, a string value is still accepted, though it won't produce any results.

I am afraid that this statement is still valid. BUT I can try to write my own tool on this. What exactly does it do? It fill this field with a text string? I have an idea how to do it if it is so.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 11, 2019, 11:10:26 am
I just made a quick suggestion and now I realize my mistake: What you want is not filling the image with text, but filling the image with a bit mask. I'm on it!

bad code for text fill:

Code: QB64: [Select]
  1. DIM Row$(1 TO 8)
  2.  
  3. 'make red-brick wall
  4. Row$(1) = CHR$(&H0) + CHR$(&H0) + CHR$(&HFE) + CHR$(&HFE)
  5. Row$(2) = Row$(1)
  6. Row$(3) = Row$(1)
  7. Row$(4) = CHR$(&H0) + CHR$(&H0) + CHR$(&H0) + CHR$(&H0)
  8. Row$(5) = CHR$(&H0) + CHR$(&H0) + CHR$(&HEF) + CHR$(&HEF)
  9. Row$(6) = Row$(5)
  10. Row$(7) = Row$(5)
  11. Row$(8) = Row$(4)
  12. Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8)
  13. LINE (59, 124)-(581, 336), 14, B 'yellow box border to paint inside
  14.  
  15. PPAINT 320, 240, 15, 14, Tile$ 'paints brick tiles within yellow border
  16.  
  17.     D = _DEST
  18.     PAINT (X, Y), c1, c2
  19.         CASE 0: LOCATE Y, X: PRINT s$: EXIT SUB
  20.         CASE 1: bh = 256
  21.         CASE 4: bh = 32
  22.     END SELECT
  23.     virtualTXT = _NEWIMAGE(_WIDTH, _HEIGHT, bh)
  24.  
  25.     COLOR c1
  26.         FOR X = 1 TO _WIDTH STEP _PRINTWIDTH(s)
  27.             _PRINTSTRING (X, Y), s$, virtualTXT
  28.     NEXT X, Y
  29.  
  30.     virtual = _NEWIMAGE(_WIDTH(D), _HEIGHT(D), bh)
  31.     _PUTIMAGE , D, virtual
  32.     _CLEARCOLOR c1, virtual
  33.     _PUTIMAGE , virtual, virtualTXT
  34.  
  35.     _PUTIMAGE , virtualTXT, _DISPLAY
  36.  
  37.     _FREEIMAGE virtual
  38.     _FREEIMAGE virtualTXT
  39.  
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 11, 2019, 11:17:18 am
How does it work correctly according to the original definition of QB4.5 for the PAINT command? Is the string a maximum of 32 bits (4 bytes) per line, or long as the format string line (* 8)? I'll try it for a maximum length of 4 bytes (although I don't know if it should be so.)
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: bplus on November 11, 2019, 11:56:57 am
OK maybe it doesn't say on Wiki but in the IDE help I get this message below example #3 (also not in Wiki)

It says Tiling (like with Tile$) doesn't work in QB64.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: bplus on November 11, 2019, 12:04:53 pm
Here's some bricks :)
Code: QB64: [Select]
  1. CONST white = &HFFFFFFFF
  2. CONST black = &HFF000000
  3. CONST red = &HFFFF0000
  4. CONST grey = &HFF7C7C7C
  5. CONST darkgrey = &HFF323232
  6.  
  7. DIM SHARED scrn&, background&, brick&, halfBrick&
  8.  
  9. scrn& = _NEWIMAGE(800, 600, 32)
  10. SCREEN scrn&
  11. makeBrick
  12. makeHalfBrick
  13. MakeBackground
  14. _DEST display& '<<< or just plain 0
  15. gameover$ = "false"
  16.     CLS
  17.     _PUTIMAGE (0, 0), background&
  18.     _DISPLAY
  19.     _LIMIT 60
  20. LOOP UNTIL gameover$ = "true"
  21.     _DISPLAY
  22.  
  23. 'for ease of brick laying I made 1 brick 49 wide and 24 high so next brick starts 50 before or after or 25 above or below
  24. SUB makeBrick ()
  25.     brick& = _NEWIMAGE(50, 25, 32)
  26.     _DEST brick&
  27.     LINE (0, 0)-STEP(49, 24), darkgrey, BF
  28.     LINE (1, 1)-STEP(46, 20), red, BF
  29.     LINE (1, 0)-STEP(46, 0), white
  30.     LINE (47, 0)-STEP(0, 21), white
  31.     LINE (0, 0)-STEP(0, 22), black
  32.     LINE (0, 0 + 22)-STEP(47, 0), black
  33.  
  34. SUB makeHalfBrick ()
  35.     halfBrick& = _NEWIMAGE(25, 25, 32)
  36.     _DEST halfBrick&
  37.     '_SOURCE brick&   '<<< not needed
  38.  
  39.     'oh the left side of the half bricks on right edge are off, need more space
  40.     _PUTIMAGE (0, 0)-(25, 25), brick&, halfBrick&, (25, 0)-(50, 25)
  41.     'need to add black line on left side
  42.     LINE (0, 0)-STEP(0, 22), black 'EDIT add a black line to left side of half brick
  43.  
  44.  
  45. SUB MakeBackground
  46.     background& = _NEWIMAGE(800, 600)
  47.     _DEST background&
  48.     'make sky
  49.     LINE (0, 0)-(800, 460), &HFF00AAFF, BF
  50.     i = 0
  51.     FOR y = 450 TO 600 STEP 25 'all bricks start 25 pixels after last
  52.         i = (i + 1) MOD 2
  53.         IF i MOD 2 THEN adj = 25 ELSE adj = 0
  54.         FOR x = 0 + adj TO 800 - 2 * adj STEP 50 'all bricks start 50 pxels after last
  55.             _PUTIMAGE (x, y), brick&, background&
  56.         NEXT
  57.         IF i THEN _PUTIMAGE (0, y), halfBrick&, background&
  58.         IF i THEN _PUTIMAGE (775, y), halfBrick&, background&
  59.     NEXT
  60.  
  61.  
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 11, 2019, 12:21:47 pm
So I have a result. I converted the strings into individual bits and used them to render the mask. Then, using transparency, I put an image with the original screen without a fill over the mask image. The result is a filling image. I did this by slow methods because I am still not quite sure about use AND for convert to bits. I do not know if it should be, or should be fill across the entire rectangle frame next to the frame, I would need to see the result under QB4.5 to tune the program (and a new brain, 3 coffee, and mainly peace and quiet...)

Tested just for 8 bit screens!

Code: QB64: [Select]
  1. DIM Row$(1 TO 8)
  2.  
  3. 'make red-brick wall
  4. Row$(1) = CHR$(&H0) + CHR$(&H0) + CHR$(&HFE) + CHR$(&HFE)
  5. Row$(2) = Row$(1)
  6. Row$(3) = Row$(1)
  7. Row$(4) = CHR$(&H0) + CHR$(&H0) + CHR$(&H0) + CHR$(&H0)
  8. Row$(5) = CHR$(&H0) + CHR$(&H0) + CHR$(&HEF) + CHR$(&HEF)
  9. Row$(6) = Row$(5)
  10. Row$(7) = Row$(5)
  11. Row$(8) = Row$(4)
  12. Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8)
  13. LINE (59, 124)-(581, 336), 14, B 'yellow box border to paint inside
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. PPAINT 320, 240, 15, 14, Tile$ 'paints brick tiles within yellow border
  21.  
  22.  
  23.     PAINT (X, Y), c1, c2
  24.     D = _DEST
  25.  
  26.     'create mask:
  27.  
  28.     ROWS = LEN(s$) \ 4
  29.     DIM R(ROWS) AS STRING '* 32
  30.  
  31.     FOR M = 1 TO LEN(s) - 4 STEP 4
  32.         FOR row = M TO M + 4
  33.             st$ = st$ + DECtoBIN$(ASC(s, row))
  34.         NEXT row
  35.         R(i) = st$
  36.         st$ = ""
  37.         i = i + 1
  38.     NEXT M
  39.  
  40.         CASE 0: LOCATE Y, X: PRINT s$: EXIT SUB
  41.         CASE 1: bh = 256
  42.         CASE 4: bh = 32
  43.     END SELECT
  44.     virtualTXT = _NEWIMAGE(_WIDTH, _HEIGHT, bh)
  45.     _DEST virtualTXT
  46.     Lin = 0
  47.     Colum = 0
  48.  
  49.     FOR Y = 1 TO _HEIGHT
  50.         FOR X = 1 TO _WIDTH
  51.             Colum = Colum + 1
  52.             IF Colum > 32 THEN Colum = 1
  53.             IF MID$(R(Lin), Colum, 1) = "1" THEN
  54.                 PSET (X, Y), c1
  55.             ELSE
  56.                 '                PSET (X, Y), c2
  57.             END IF
  58.         NEXT X
  59.         Lin = Lin + 1
  60.         IF Lin > UBOUND(r) THEN Lin = LBOUND(r)
  61.     NEXT Y
  62.  
  63.  
  64.     virtual = _NEWIMAGE(_WIDTH(D), _HEIGHT(D), bh)
  65.     _DEST virtual
  66.     _PUTIMAGE , D, virtual
  67.     _CLEARCOLOR c1, virtual
  68.     _PUTIMAGE , virtual, virtualTXT
  69.  
  70.     _PUTIMAGE , virtualTXT, _DISPLAY
  71.  
  72.  
  73.     _FREEIMAGE virtual
  74.     _FREEIMAGE virtualTXT
  75.  
  76. FUNCTION DECtoBIN$ (vstup)
  77.     FOR rj = 7 TO 0 STEP -1
  78.         IF vstup AND 2 ^ rj THEN DECtoBIN$ = DECtoBIN$ + "1" ELSE DECtoBIN$ = DECtoBIN$ + "0"
  79.     NEXT rj
  80.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: FellippeHeitor on November 11, 2019, 12:26:31 pm
Some bits in there set colors too. This is rendered red in QBasic.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: FellippeHeitor on November 11, 2019, 12:26:57 pm
And without the gaps.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 11, 2019, 12:42:08 pm
Hi Fellippe, Could you add a picture? I'll try to find it.

You say without spaces. This means that some bytes control color. Well, I'm going to look.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: FellippeHeitor on November 11, 2019, 01:36:45 pm
There.
 [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 11, 2019, 02:55:34 pm
Thank you.


Well, I can't figure it out. I looked at the Qbasic book and it says that the colors are coded into individual bytes (so, since SCREEN 12 is 4 bit, one byte should carry a 2 pixel color), but the correct color numbers do not match. I do not understand where it takes information about red, when the first two bytes are always zero...  it also seems that the bits in the first two bytes may control the bit mask laying method, which seems to be in the last two bytes. But they're all my assumptions, unsubstantiated. I'll try later, I'm hungry. I try later to add AND for background color cooperations, if it help...
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 12, 2019, 09:21:39 am
Hi
thanks for your time!

1.
tiling is not supported in QB64. I know this also for LINE command!
I have been surprised that there is an example in Wiki of PAINT.

2. about tiling how Qbasic does it....
I can confirm that it is a red wall of bricks also in my Qbasic under Dosbox.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

observing the CHR$ of Tile$ it uses &Hvalue,  3 same value and a forth zero for the 4 values (Row$) while it uses another 3 &H value for the first 3 value of second 4 Row$ and a final zero (the eightth Row$).

I have got strange results using just Row$(1) and/or Row$(5) as Tile$ of PAINT, while Row$(4) or Ror$(8) gives a black square.
So we can assume that using the pattern a decoder mask choose color and what pixel to color!



Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 13, 2019, 08:55:38 am
Hi Bplus
your bricks are very beautyful!
Thanks also for blu sky!
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: bplus on November 13, 2019, 10:56:46 am
Hi TempodiBasic,

You know, it is an interesting problem to "paint" a tile pattern, you've got me thinking (and Petr looks to be making good progress). I know Steve and I did "paint" balls of assorted sizes and colors in a defined rectangular area but "PAINTing" with a colored tile pattern in every nook and cranny not bounded by enclosed areas is a thinker... :)
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 13, 2019, 01:05:32 pm
So. Maybe! Maybe. I am not really 100 percent sure. This is now QB64 output:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

It just confirmed that I must to sit down because i am something to read and not accept.... So. The first two bytes are MAYBE useless, the color problem seems to solve the screen mode directly. Or it is a coincidence and the number 4 will be coded in some way in the first two bytes. Here is the source code to explore.

Code: QB64: [Select]
  1. DIM Row$(1 TO 8)
  2.  
  3. 'make red-brick wall
  4. Row$(1) = CHR$(&H0) + CHR$(&H0) + CHR$(&HFE) + CHR$(&HFE)
  5. Row$(2) = Row$(1)
  6. Row$(3) = Row$(1)
  7. Row$(4) = CHR$(&H0) + CHR$(&H0) + CHR$(&H0) + CHR$(&H0)
  8. Row$(5) = CHR$(&H0) + CHR$(&H0) + CHR$(&HEF) + CHR$(&HEF)
  9. Row$(6) = Row$(5)
  10. Row$(7) = Row$(5)
  11. Row$(8) = Row$(4)
  12. Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8)
  13. LINE (59, 124)-(581, 336), 14, B 'yellow box border to paint inside
  14.  
  15.  
  16. PPAINT 320, 240, 15, 14, Tile$ 'paints brick tiles within yellow border
  17.  
  18.  
  19.     PAINT (X, Y), c1, c2
  20.     D = _DEST
  21.  
  22.     'create mask:
  23.  
  24.     ROWS = LEN(s$) \ 4
  25.     DIM R(ROWS) AS STRING '* 32
  26.  
  27.     FOR M = 3 TO LEN(s) - 4 STEP 4 '                                start on byte 3 in text (first two bytes in are always 0, this must be key for color, but how...
  28.         FOR row = M TO M + 4
  29.             st$ = st$ + DECtoBIN$(ASC(s, row))
  30.         NEXT row
  31.         R(i) = st$
  32.         st$ = ""
  33.         i = i + 1
  34.     NEXT M
  35.  
  36.         CASE 0: LOCATE Y, X: PRINT s$: EXIT SUB
  37.         CASE 1: bh = 256
  38.         CASE 4: bh = 32
  39.     END SELECT
  40.     virtualTXT = _NEWIMAGE(_WIDTH, _HEIGHT, bh)
  41.     _DEST virtualTXT
  42.     Lin = 0
  43.     Colum = 0
  44.  
  45.     FOR Y = 1 TO _HEIGHT
  46.         FOR X = 1 TO _WIDTH
  47.             Colum = Colum + 1
  48.             IF Colum > 16 THEN Colum = 1 '                            upgraded to 16, because now we read 2 bytes, not 4
  49.  
  50.             IF MID$(R(Lin), Colum, 1) = "1" THEN
  51.                 PSET (X, Y), c1 AND 4 '                               SCREEN 12 is 4 bit screen
  52.             ELSE
  53.                 REM PSET (X, Y), c2
  54.             END IF
  55.         NEXT X
  56.         Lin = Lin + 1
  57.         IF Lin > UBOUND(r) THEN Lin = LBOUND(r)
  58.     NEXT Y
  59.  
  60.  
  61.     virtual = _NEWIMAGE(_WIDTH(D), _HEIGHT(D), bh)
  62.     _DEST virtual
  63.     _PUTIMAGE , D, virtual
  64.     _CLEARCOLOR c1, virtual
  65.     _PUTIMAGE , virtual, virtualTXT
  66.  
  67.     _PUTIMAGE , virtualTXT, _DISPLAY
  68.  
  69.  
  70.     _FREEIMAGE virtual
  71.     _FREEIMAGE virtualTXT
  72.  
  73. FUNCTION DECtoBIN$ (vstup)
  74.     FOR rj = 7 TO 0 STEP -1
  75.         IF vstup AND 2 ^ rj THEN DECtoBIN$ = DECtoBIN$ + "1" ELSE DECtoBIN$ = DECtoBIN$ + "0"
  76.     NEXT rj
  77.  

Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 13, 2019, 01:51:33 pm
So unfortunately, the color I'm looking for is the number 12. I can't figure out how to get that number. I add binary decomposition of the given painting, maybe someone find how the color number is written.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

If is really color writed as 4-bites number, then you search 1100.

Used code:

Code: [Select]
DIM Row$(1 TO 8)
SCREEN 12

'make red-brick wall
Row$(1) = CHR$(&H0) + CHR$(&H0) + CHR$(&HFE) + CHR$(&HFE)
Row$(2) = Row$(1)
Row$(3) = Row$(1)
Row$(4) = CHR$(&H0) + CHR$(&H0) + CHR$(&H0) + CHR$(&H0)
Row$(5) = CHR$(&H0) + CHR$(&H0) + CHR$(&HEF) + CHR$(&HEF)
Row$(6) = Row$(5)
Row$(7) = Row$(5)
Row$(8) = Row$(4)

FOR r = 1 TO 8
    FOR f = 1 TO LEN(Row$(r))
        PRINT DECtoBIN(ASC(Row$(r), f)); " ";
    NEXT
    PRINT "        Row:"; r
NEXT

PRINT
PRINT "Searching string for number 12 (wall color), binary "; DECtoBIN$(12); " but i see it not"
FUNCTION BINtoDEC (b AS STRING)
    FOR Si = 1 TO LEN(b)
        e$ = MID$(b$, Si, 1)
        c = VAL(e$) '
        Sj = LEN(b) - Si
        BINtoDEC = BINtoDEC + (c * 2 ^ Sj)
    NEXT Si
END FUNCTION

FUNCTION DECtoBIN$ (vstup)
    FOR rj = 7 TO 0 STEP -1
        IF vstup AND 2 ^ rj THEN DECtoBIN$ = DECtoBIN$ + "1" ELSE DECtoBIN$ = DECtoBIN$ + "0"
    NEXT rj
END FUNCTION
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 13, 2019, 06:43:58 pm
Colors aren't coded the way you think they are.   The usage depends of screen mode.

In monochrome (screen 2, screen 11...) the usage is very easy:
The tile MUST have a width of 8 bit, and can have a variable height.
You draw the tile by converting the bit-matrix to bytes.

Example (drawing a cross):
00001000=8
00001000=8
00001000=8
11111111=255
00001000=8
00001000=8
00001000=8

So the program:
Code: [Select]

screen 11
paint (10,10),chr$(8)+chr$(8)+chr$(8)+chr$(255)+chr$(8)+chr$(8)+chr$(8)

Will draw a "grid" (tiled crosses)

In 16 color modes, every line is 4-byte long (2^4=16): one byte sets the red attribute, one the green, one the blue, one the brightess of the eight pixels of the line.

In 256-color mode, you will need 8 bytes for every line (2^8=256).
So you can't use the same tile string in different screen modes unless they have the same number of colors (i.e. screen 7,8,12 are compatible)
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 13, 2019, 06:59:12 pm
Testing in QB45 seems to support the previous notes.

SCREEN 12
LINE (40,120)-(320,270), 14, B
PAINT (120,140), CHR$(0) + CHR$(0) + CHR$(255) + CHR$(255), 14

The above will paint us with a RED fill color

Change that to CHR$(0) + CHR$(255) + CHR$(0) + CHR$(255) and we get a GREEN fill color. 
CHR$(255) + CHR$(0) + CHR$(0) + CHR$(255) gives us a BLUE fill color.


Play around with it a bit, and maybe it'll help you figure out the way it's supposed to act in QB45. 

So, when you wonder where your red is coming from , it's from these lines:
CHR$(&H0) + CHR$(&H0) + CHR$(&HFE) + CHR$(&HFE)  ==>  No Blue + No Green + High Red + High Intensity
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 13, 2019, 07:09:41 pm
Grat Job Petr  you got it!

I can confirm that in Qbasic changing the border color (14) has no affect on the color red used to fill the brick of the wall!

Yes, also changing value of arguments of CHR$( ) I got in Qbasic different patterns but the same color red 12
moreover also changing SCREEN mode from 12 to 9 the color of the wall is always red! And also the other patterns are red!
A red word! :-)

Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 13, 2019, 07:16:56 pm
Hi Steve
thanks to put out the Meta command of the RGBA in Tiling of QB45!
So it seems that if I want a brick tiling I can get only a red brick in the SCREEN 12  and SCREEN 9!

If it is so I can affirm, for my point of view, that masking for aspect of tile is great, but it is so poor for choose a color to paint because it forces to have a pattern only with fixed color, moreover you cannot disable the Mask color attribute and use only the masktiling with the color already set by the before graphic command/action!

Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 13, 2019, 07:48:28 pm
Actually, I think I was looking at the color values wrong.  The old notes I found were right, my understanding of them was wrong.

Each line is 4 bytes in screen 12 -- Look at your screenshot above.

00000000       00000000     111111110       11111110  -- this is a single line....  If you wanted to know what its color value translates to in screen 12 colors, your colors would be pieced together from those 4 bytes.

For example, let's say I want a RED dot in the first spot, then a black dot, then a blue dot, then all black dots:

00100000      00000000      10000000     10100000

If you look at the first byte, you'll see that I want blue in the 3rd pixel only.  Looking at the third byte, you'll see that I only want red in the 1st pixel only.  And I want them to be the high intensity versions, when I use them, according to the last byte.

To make the first pixel yellow, it'd be:

00000000      10000000      10000000      10000000

no blue --- green in the first pixel --- red in the first pixel --- and high intensity colors.




Try with the above to generate your patterns.  I think I've finally deciphered what those old notes mean, in this case.  ;)
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 14, 2019, 07:26:38 am
Thanks I'll try later to put all together this informations into a running code.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 14, 2019, 07:56:20 am
Thanks I'll try later to put all together this informations into a running code.

If it helps, here's an example of a blue on red cross in QB45 in SCREEN 12:

Code: QB64: [Select]
  1.  
  2. 'Cross Pattern -- 0 is RED, 1 is BLUE
  3. '00011000   = 24
  4. '00011000
  5. '11111111   = 255
  6. '00011000
  7. '00011000
  8. '00011000
  9. '00011000
  10.  
  11. r1$ = CHR$(128 + 64 + 32 + 0 + 0 + 4 + 2 + 1) 'Turn Bit values into a CHR$ value for each row
  12. r2$ = CHR$(0 + 0 + 0 + 0 + 0 + 0 + 0 + 0) 'And we only have 2 rows in total which we use as our building blocks for this cross pattern
  13.  
  14. b1$ = CHR$(0 + 0 + 0 + 16 + 8 + 0 + 0 + 0)
  15. b2$ = CHR$(128 + 64 + 32 + 16 + 8 + 4 + 2 + 1)
  16.  
  17. g$ = CHR$(0) 'No green in this pattern
  18. a$ = CHR$(0) 'And we want the dark colors.  If we set the bits here, we'd get the light colors.
  19.  
  20. tile$ = tile$ + b1$ + g$ + r1$ + a$
  21. tile$ = tile$ + b1$ + g$ + r1$ + a$
  22. tile$ = tile$ + b2$ + g$ + r2$ + a$
  23. tile$ = tile$ + b2$ + g$ + r2$ + a$
  24. tile$ = tile$ + b1$ + g$ + r1$ + a$
  25. tile$ = tile$ + b1$ + g$ + r1$ + a$
  26. tile$ = tile$ + b1$ + g$ + r1$ + a$
  27. tile$ = tile$ + b1$ + g$ + r1$ + a$
  28.  
  29. LINE (20, 20)-(240, 240), 14, B
  30. PAINT (21, 21), tile$, 14
  31.  

Run the above in QB45 and you'll get a nice image as a good cross pattern which will fill up the box we defined earlier.  ;)

Hopefully a solid, working example will help highlight how to build (and decipher) the tile$ for use in 16 color screens. 
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 14, 2019, 11:04:38 am
Thank you Steve for a detailed analysis. I had nothing how orientate, so I tried to apply my assumption (as seen, so bad). I'll try somewhere to download the QB4.5 + dosbox for tests. If everything works as I suppose, maybe one old backlog could be solved in QB64? Even a completely new set of 32-bit color instructions could be applied? :) I will continue to experiment with it. It's a nice thing.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 14, 2019, 04:45:18 pm
Thank you Steve for a detailed analysis. I had nothing how orientate, so I tried to apply my assumption (as seen, so bad). I'll try somewhere to download the QB4.5 + dosbox for tests. If everything works as I suppose, maybe one old backlog could be solved in QB64? Even a completely new set of 32-bit color instructions could be applied? :) I will continue to experiment with it. It's a nice thing.

Here's a quick and easy workup of paint tiling, using Bplus's little paintimage routine (modified to work with screen 12 screens), with a quick StringToTile16 function to create the 8x8 tile for us.  See if it doesn't mimic QB45's natural paint routine for you.  ;)

Code: QB64: [Select]
  1.  
  2. 'red cross pattern on black background
  3. '00011000
  4. '11111111
  5. '11111111
  6. '00011000
  7. '00011000
  8. '00011000
  9. '00011000
  10. '00011000
  11.  
  12.  
  13.  
  14.  
  15. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  16. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0)
  17. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0)
  18. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  19. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  20. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  21. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  22. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  23.  
  24. tileimage = StringToTile16(text$)
  25.  
  26. LINE (20, 20)-(240, 240), 14, B
  27.  
  28. paintImage 21, 21, 14, 0, tileimage
  29.  
  30. _PUTIMAGE (300, 100)-STEP(100, 100), tileimage
  31. LINE (300, 100)-STEP(100, 100), 14, B 'just to highlight our tile pattern
  32.  
  33.  
  34. FUNCTION StringToTile16 (text$)
  35.     d = _DEST: s = _SOURCE
  36.     tempimage = _NEWIMAGE(8, 8, 12)
  37.     _DEST tempimage: _SOURCE tempimage
  38.     FOR y = 0 TO 7
  39.         line$ = MID$(text$, y * 4 + 1, 4)
  40.         b = ASC(line$, 1) 'blue
  41.         g = ASC(line$, 2) 'green
  42.         r = ASC(line$, 3) 'red
  43.         a = ASC(line$, 4) 'alpha (intensity)
  44.         FOR x = 0 TO 7
  45.             p = 2 ^ x 'position to check
  46.             bp = b AND p
  47.             gp = g AND p
  48.             rp = r AND p
  49.             ap = a AND p
  50.             IF ap THEN zero = 85 ELSE zero = 0
  51.             IF bp THEN blue = 170 + zero ELSE blue = zero
  52.             IF gp THEN green = 170 + zero ELSE green = zero
  53.             IF rp THEN red = 170 + zero ELSE red = zero
  54.             PSET (x, y), _RGB(red, green, blue)
  55.         NEXT
  56.     NEXT
  57.     _DEST d: _SOURCE s
  58.     StringToTile16 = tempimage
  59.  
  60.  
  61.  
  62.  
  63.  
  64. SUB paintImage (x, y, Border~&, destHandle&, imageHandle&)
  65.     d = _DEST: s = _SOURCE
  66.     _DEST destHandle&
  67.     PAINT (x, y), _RGB(119, 24, 49), Border~&
  68.     FOR y = 0 TO _HEIGHT(destHandle&)
  69.         FOR x = 0 TO _WIDTH(destHandle&)
  70.             _SOURCE destHandle&
  71.             IF POINT(x, y) = _RGB(119, 24, 49) THEN
  72.                 _SOURCE imageHandle&
  73.                 PSET (x, y), POINT(x MOD _WIDTH(imageHandle&), y MOD _HEIGHT(imageHandle&))
  74.             END IF
  75.         NEXT
  76.     NEXT
  77.     _DEST d: _SOURCE s
  78.  
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on November 15, 2019, 09:25:25 am
Perfect work, Steve! Your code work as expected and with TempodiBasic's string it draw correct brick! How you find values 85 and 170 in your StringToTile16 function? Yes, 170 + 85 is maximum, 255, but how you find value 170? It is with comparation between expected output in QB4.5 and your program, or how?
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 15, 2019, 09:43:22 am
Perfect work, Steve! Your code work as expected and with TempodiBasic's string it draw correct brick! How you find values 85 and 170 in your StringToTile16 function? Yes, 170 + 85 is maximum, 255, but how you find value 170? It is with comparation between expected output in QB4.5 and your program, or how?

SCREEN 12
FOR I = 0 TO 15
   PRINT I, _BLUE(I), _GREEN(I), _RED(I)
NEXT

Only values that print are 0, 85, 170, and 225.

After studying the values a bit, I noticed that the first 8 colors were all 170 or 0 (red, green, blue flag set, or not).  The second 8 values were exactly the same; just 85 higher for the high intensity colors.

Their is one color on the chart which is off pattern, which I can’t help but wonder if it’s a bug in QB64’s default palette, since all the rest follow the rule perfectly.  Maybe QB45 had the same “glitch” and we simply work to duplicate it perfectly? 

As long as we use _RGB, it doesn’t seem to matter: the color (0, 170, 170) still matches closest to (0, 85, 170), so we don’t need to code an exception to the little rules I created for my tile maker.  Still though, I can’t help but wonder, “Why is that one color different from the pattern with all the others??”  ;)
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 15, 2019, 12:54:28 pm
Hey Steve
excellent work! I have renamed your new code  "Paint Tiling Steve's QB45 Emulator.BAS".
Now I work to get a not red brickswall!
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 15, 2019, 01:20:47 pm
Hey Steve
excellent work! I have renamed your new code  "Paint Tiling Steve's QB45 Emulator.BAS".
Now I work to get a not red brickswall!

Easiest way is to map out your filer with 0s and 1s for each of the 3 colors you want.

Your wall fill is currently:

BLUE
00000000
00000000
00000000
00000000
00000000
00000000
00000000

GREEN
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000

RED
00000000
11111110
11111110
11111110
00000000
01111111
01111111
01111111

If you want a blue wall, just swap Red and Blue’s positions.  For a yellow wall, make green the same as reds.   A white wall has blue, green, red all matching.

That’s all it is to get the tiles.  Just use CHR$(&B00000000) to set those values as needed.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 15, 2019, 07:15:41 pm
Thanks Steve
in the while I'm playing with the ideas that you give above and so I got this scheme
Code: QB64: [Select]
  1. ' Name             String full color                        AttributeColor       Non Zero Value (255=full)
  2. '        blu        green     red       light
  3. SBlack = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) '                 0             0 255
  4.  
  5. Sblu = CHR$(255) + CHR$(0) + CHR$(0) + CHR$(0) '                 1             1 SOLO 255
  6. Sgreen = CHR$(0) + CHR$(255) + CHR$(0) + CHR$(0) '               2
  7. Sred = CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0) '                 4
  8. Sgray = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(255) '                8
  9.  
  10. Scyan = CHR$(255) + CHR$(255) + CHR$(0) + CHR$(0) '              3              2 SOLI 255
  11. Sporpora = CHR$(255) + CHR$(0) + CHR$(255) + CHR$(0) '           5
  12. Sviolet = CHR$(255) + CHR$(0) + CHR$(0) + CHR$(255) '            9
  13. Sbrown = CHR$(0) + CHR$(255) + CHR$(255) + CHR$(0) '             6
  14. SgreenLight = CHR$(0) + CHR$(255) + CHR$(0) + CHR$(255) '       10
  15. SredLight = CHR$(0) + CHR$(0) + CHR$(255) + CHR$(255) '         12
  16.  
  17. Swhite = CHR$(255) + CHR$(255) + CHR$(255) + CHR$(0) '           7              3 255
  18. Sceleste = CHR$(255) + CHR$(255) + CHR$(0) + CHR$(255) '        11
  19. Spink = CHR$(255) + CHR$(0) + CHR$(255) + CHR$(255) '           13
  20. Syellow = CHR$(0) + CHR$(255) + CHR$(255) + CHR$(255) '         14
  21.  
  22. SwhiteLight = CHR$(255) + CHR$(255) + CHR$(255) + CHR$(255) '   15             4 255
  23. ' using a value in the range 1-254 we get some masks

so here a different color for brick-wall using your Paint Tiling QB45 Emulator
Code: QB64: [Select]
  1. DEFLNG A-Z
  2.  
  3. DIM Row$(1 TO 8)
  4. 'make Sporpora-brick wall
  5. Row$(1) = CHR$(&HFE) + CHR$(&H0) + CHR$(&HFE) + CHR$(&H0)
  6. Row$(2) = Row$(1)
  7. Row$(3) = Row$(1)
  8. Row$(4) = CHR$(&H0) + CHR$(&H0) + CHR$(&H0) + CHR$(&H0)
  9. Row$(5) = CHR$(&HEF) + CHR$(&H0) + CHR$(&HEF) + CHR$(&H0)
  10. Row$(6) = Row$(5)
  11. Row$(7) = Row$(5)
  12. Row$(8) = Row$(4)
  13. Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8)
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. 'red cross pattern on black background
  22. '00011000
  23. '11111111
  24. '11111111
  25. '00011000
  26. '00011000
  27. '00011000
  28. '00011000
  29. '00011000
  30.  
  31. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  32. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0)
  33. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0)
  34. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  35. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  36. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  37. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  38. 'text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  39.  
  40. text$ = Tile$
  41.  
  42. tileimage = StringToTile16(text$)
  43.  
  44.  
  45. LINE (20, 20)-(240, 240), 14, B
  46. paintImage 21, 21, 14, 0, tileimage
  47. _PUTIMAGE (300, 100)-STEP(100, 100), tileimage
  48. LINE (300, 100)-STEP(100, 100), 14, B 'just to highlight our tile pattern
  49.  
  50. FUNCTION StringToTile16 (text$)
  51.     d = _DEST: s = _SOURCE
  52.     tempimage = _NEWIMAGE(8, 8, 12)
  53.     _DEST tempimage: _SOURCE tempimage
  54.     FOR y = 0 TO 7
  55.         LINE$ = MID$(text$, y * 4 + 1, 4)
  56.         b = ASC(LINE$, 1) 'blue
  57.         g = ASC(LINE$, 2) 'green
  58.         r = ASC(LINE$, 3) 'red
  59.         a = ASC(LINE$, 4) 'alpha (intensity)
  60.         FOR x = 0 TO 7
  61.             p = 2 ^ x 'position to check
  62.             bp = b AND p
  63.             gp = g AND p
  64.             rp = r AND p
  65.             ap = a AND p
  66.             IF ap THEN zero = 85 ELSE zero = 0
  67.             IF bp THEN blue = 170 + zero ELSE blue = zero
  68.             IF gp THEN green = 170 + zero ELSE green = zero
  69.             IF rp THEN red = 170 + zero ELSE red = zero
  70.             PSET (x, y), _RGB(red, green, blue)
  71.         NEXT
  72.     NEXT
  73.     _DEST d: _SOURCE s
  74.     StringToTile16 = tempimage
  75.  
  76.  
  77.  
  78.  
  79.  
  80. SUB paintImage (x, y, Border~&, destHandle&, imageHandle&)
  81.     d = _DEST: s = _SOURCE
  82.     _DEST destHandle&
  83.     PAINT (x, y), _RGB(119, 24, 49), Border~&
  84.     FOR y = 0 TO _HEIGHT(destHandle&)
  85.         FOR x = 0 TO _WIDTH(destHandle&)
  86.             _SOURCE destHandle&
  87.             IF POINT(x, y) = _RGB(119, 24, 49) THEN
  88.                 _SOURCE imageHandle&
  89.                 PSET (x, y), POINT(x MOD _WIDTH(imageHandle&), y MOD _HEIGHT(imageHandle&))
  90.             END IF
  91.         NEXT
  92.     NEXT
  93.     _DEST d: _SOURCE s
  94.  
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 16, 2019, 06:58:06 am
Hi Steve
playing just a bit more with your Informations I can affirm that your QB45 PaintTiling emulator is Cool!

here an example about how it is versatle using &B as mask for tiling
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Code: QB64: [Select]
  1.  
  2. 'red cross pattern on black background
  3. '00011000
  4. '11111111
  5. '11111111
  6. '00011000
  7. '00011000
  8. '00011000
  9. '00011000
  10. '00011000
  11.  
  12. '       Binary scheme gives direct more powerful control of mask
  13. '                      Blu                 Green               Red             Light
  14. text$ = text$ + CHR$(&B00011000) + CHR$(&B00011000) + CHR$(&B11100111) + CHR$(&B00000000)
  15. text$ = text$ + CHR$(&B00000000) + CHR$(&B11111111) + CHR$(&B11100111) + CHR$(&B00000000)
  16. text$ = text$ + CHR$(&B00000000) + CHR$(&B11111111) + CHR$(&B11100111) + CHR$(&B00000000)
  17. text$ = text$ + CHR$(&B00011000) + CHR$(&B00011000) + CHR$(&B11100111) + CHR$(&B00000000)
  18. text$ = text$ + CHR$(&B00011000) + CHR$(&B00000000) + CHR$(&B11100111) + CHR$(&B00000000)
  19. text$ = text$ + CHR$(&B00011000) + CHR$(&B00000000) + CHR$(&B11100111) + CHR$(&B00000000)
  20. text$ = text$ + CHR$(&B00011000) + CHR$(&B00000000) + CHR$(&B11100111) + CHR$(&B00000000)
  21. text$ = text$ + CHR$(&B00011000) + CHR$(&B00011000) + CHR$(&B11100111) + CHR$(&B00000000)
  22.  
  23.  
  24.  
  25. tileimage = StringToTile16(text$)
  26. LINE (20, 20)-(240, 240), 14, B
  27. paintImage 21, 21, 14, 0, tileimage
  28. _PUTIMAGE (300, 100)-STEP(100, 100), tileimage
  29. LINE (300, 100)-STEP(100, 100), 14, B 'just to highlight our tile pattern
  30.  
  31. FUNCTION StringToTile16 (text$)
  32.     d = _DEST: s = _SOURCE
  33.     tempimage = _NEWIMAGE(8, 8, 12)
  34.     _DEST tempimage: _SOURCE tempimage
  35.     FOR y = 0 TO 7
  36.         LINE$ = MID$(text$, y * 4 + 1, 4)
  37.         b = ASC(LINE$, 1) 'blue
  38.         g = ASC(LINE$, 2) 'green
  39.         r = ASC(LINE$, 3) 'red
  40.         a = ASC(LINE$, 4) 'alpha (intensity)
  41.         FOR x = 0 TO 7
  42.             p = 2 ^ x 'position to check
  43.             bp = b AND p
  44.             gp = g AND p
  45.             rp = r AND p
  46.             ap = a AND p
  47.             IF ap THEN zero = 85 ELSE zero = 0
  48.             IF bp THEN blue = 170 + zero ELSE blue = zero
  49.             IF gp THEN green = 170 + zero ELSE green = zero
  50.             IF rp THEN red = 170 + zero ELSE red = zero
  51.             PSET (x, y), _RGB(red, green, blue)
  52.         NEXT
  53.     NEXT
  54.     _DEST d: _SOURCE s
  55.     StringToTile16 = tempimage
  56.  
  57.  
  58.  
  59.  
  60.  
  61. SUB paintImage (x, y, Border~&, destHandle&, imageHandle&)
  62.     d = _DEST: s = _SOURCE
  63.     _DEST destHandle&
  64.     PAINT (x, y), _RGB(119, 24, 49), Border~&
  65.     FOR y = 0 TO _HEIGHT(destHandle&)
  66.         FOR x = 0 TO _WIDTH(destHandle&)
  67.             _SOURCE destHandle&
  68.             IF POINT(x, y) = _RGB(119, 24, 49) THEN
  69.                 _SOURCE imageHandle&
  70.                 PSET (x, y), POINT(x MOD _WIDTH(imageHandle&), y MOD _HEIGHT(imageHandle&))
  71.             END IF
  72.         NEXT
  73.     NEXT
  74.     _DEST d: _SOURCE s
  75.  
Thanks
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 16, 2019, 07:35:11 am
about
Quote
In 16 color modes, every line is 4-byte long (2^4=16): one byte sets the red attribute, one the green, one the blue, one the brightess of the eight pixels of the line.

In 256-color mode, you will need 8 bytes for every line (2^8=256).

two questions:
1. in a 32 bit mode how many bytes do we need to code color?
2. in 256 color mode  I think that the 8 bytes are grouped for the 3 cardinal values BGRA  as BBGGRRAA?
thanks
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 16, 2019, 09:08:02 am
about
two questions:
1. in a 32 bit mode how many bytes do we need to code color?
2. in 256 color mode  I think that the 8 bytes are grouped for the 3 cardinal values BGRA  as BBGGRRAA?
thanks

In 256 color mode, each byte is one pixel, IIRC.

QB45 doesn’t have a 32-bit mode, so whoever wrote the routine could make it to their specification.  Personally, I’d just make it pixel-by-pixel like 256 color mode, and it’d be 4 bytes per pixel for Blue, Green, Red, Alpha, in that order, so we could just plug it into _MEM and directly push it to the screen.
Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 16, 2019, 11:50:48 am
Well it seems that I must do your _MEM tutorial and then I must MOD your Paint Tiling QB45 emulator to _MEM power!

Quote
Q :in 256 color mode  I think that the 8 bytes are grouped for the 3 cardinal values BGRA  as BBGGRRAA?
thanks
A: In 256 color mode, each byte is one pixel, IIRC.

Q. IIRC? I have googled finding a graphic chipset of AMIGA in the 1996!

.....
one byte one pixel....
? I must remove more dust from my memory!
SCREEN 13  has 64 attribute color (0-63) for 256 colors!
so each byte brings information 0-63 !
I'll try to adapt your QB45 emulator to SCREEN 13!

Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: SMcNeill on November 16, 2019, 11:59:41 am
http://qb64.org/wiki/SCREEN

SCREEN 13 has 256 color attributes, black background.

Title: Re: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on November 24, 2019, 05:43:24 pm
Hi Steve here a first step to empower your QB45 paint tiling Emulator

now supported SCREEN 7, 8, 9 added to the original 12, and SCREEN 13.

Code: QB64: [Select]
  1. ' Name             String full color                        AttributeColor       Non Zero Value (255=full)
  2. '        blu        green     red       light
  3. SBlack = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) '                 0             0 255
  4.  
  5. Sblu = CHR$(255) + CHR$(0) + CHR$(0) + CHR$(0) '                 1             1 SOLO 255
  6. Sgreen = CHR$(0) + CHR$(255) + CHR$(0) + CHR$(0) '               2
  7. Sred = CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0) '                 4
  8. Sgray = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(255) '                8
  9.  
  10. Scyan = CHR$(255) + CHR$(255) + CHR$(0) + CHR$(0) '              3              2 SOLI 255
  11. Sporpora = CHR$(255) + CHR$(0) + CHR$(255) + CHR$(0) '           5
  12. Sviolet = CHR$(255) + CHR$(0) + CHR$(0) + CHR$(255) '            9
  13. Sbrown = CHR$(0) + CHR$(255) + CHR$(255) + CHR$(0) '             6
  14. SgreenLight = CHR$(0) + CHR$(255) + CHR$(0) + CHR$(255) '       10
  15. SredLight = CHR$(0) + CHR$(0) + CHR$(255) + CHR$(255) '         12
  16.  
  17. Swhite = CHR$(255) + CHR$(255) + CHR$(255) + CHR$(0) '           7              3 255
  18. Sceleste = CHR$(255) + CHR$(255) + CHR$(0) + CHR$(255) '        11
  19. Spink = CHR$(255) + CHR$(0) + CHR$(255) + CHR$(255) '           13
  20. Syellow = CHR$(0) + CHR$(255) + CHR$(255) + CHR$(255) '         14
  21.  
  22. SwhiteLight = CHR$(255) + CHR$(255) + CHR$(255) + CHR$(255) '   15             4 255
  23.  
  24. DEFLNG A-Z
  25. ScreenMode = 13
  26. SCREEN ScreenMode
  27.  
  28. DIM Row$(1 TO 8)
  29. 'one byte one column for a mask of 8 byte for 64 max bytes
  30. 'screen 13 has 255 colors
  31. Row$(1) = CHR$(4) + CHR$(2) + CHR$(0) + CHR$(14) + CHR$(12) + CHR$(2) + CHR$(0) + CHR$(10)
  32. Row$(2) = Row$(1)
  33. Row$(3) = Row$(1)
  34. Row$(4) = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0)
  35. Row$(5) = CHR$(3) + CHR$(3) + CHR$(1) + CHR$(1) + CHR$(14) + CHR$(14) + CHR$(15) + CHR$(11)
  36. Row$(6) = Row$(5)
  37. Row$(7) = Row$(5)
  38. Row$(8) = Row$(4)
  39. Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8)
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. 'in screen 12 mode  4 bytes for line of tile with RGBA scheme
  48. 'red cross pattern on black background
  49. 'Cross Pattern -- 0 is black, 1 is BLUE
  50. '00011000   = 24
  51. '00011000
  52. '11111111   = 255
  53. '11111111   = 255
  54. '00011000
  55. '00011000
  56. '00011000
  57. '00011000
  58. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  59. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0)
  60. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(255) + CHR$(0)
  61. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  62. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  63. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  64. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  65. text$ = text$ + CHR$(0) + CHR$(0) + CHR$(24) + CHR$(0)
  66.  
  67. text$ = Tile$ ' REM this line to test SCREEN 12, 9, 8, 7
  68.  
  69. tileimage = StringToTile16(text$, ScreenMode)
  70.  
  71.  
  72. LINE (20, 20)-(180, 180), 14, B
  73. paintImage 21, 21, 14, 0, tileimage
  74. _PUTIMAGE (250, 100)-STEP(50, 50), tileimage ' to overshow tile
  75. LINE (250, 100)-STEP(50, 50), 14, B 'just to highlight our tile pattern
  76.  
  77. ' questa e' la funzione da adattare
  78. FUNCTION StringToTile16 (text$, SMode)
  79.     DIM Bbyte AS INTEGER, RowByte AS INTEGER, Kolor AS _UNSIGNED LONG
  80.     IF SMode = 12 OR SMode = 9 OR SMode = 8 OR SMode = 7 THEN
  81.         Bbyte = 4: RowByte = 4
  82.     ELSEIF SMode = 13 THEN
  83.         Bbyte = 8: RowByte = 8
  84.     ELSE
  85.         PRINT "Error ScreenMode not supported"
  86.         StringToTile16 = 9999
  87.         EXIT FUNCTION
  88.     END IF
  89.     d = _DEST: s = _SOURCE
  90.     tempimage = _NEWIMAGE(8, 8, SMode) ' imagine 8x8  but if text$ is more than
  91.     _DEST tempimage: _SOURCE tempimage
  92.     FOR y = 0 TO 7
  93.         LINE$ = MID$(text$, y * Bbyte + 1, RowByte)
  94.         IF SMode = 12 OR SMode = 9 OR SMode = 8 OR SMode = 7 THEN
  95.             b = ASC(LINE$, 1) 'blue
  96.             g = ASC(LINE$, 2) 'green
  97.             r = ASC(LINE$, 3) 'red
  98.             a = ASC(LINE$, 4) 'alpha (intensity)
  99.         END IF
  100.  
  101.         FOR x = 0 TO 7
  102.             IF SMode = 12 OR SMode = 9 OR SMode = 8 OR SMode = 7 THEN
  103.                 p = 2 ^ x 'position to check
  104.                 bp = b AND p
  105.                 gp = g AND p
  106.                 rp = r AND p
  107.                 ap = a AND p
  108.                 IF ap THEN zero = 85 ELSE zero = 0
  109.                 IF bp THEN blue = 170 + zero ELSE blue = zero
  110.                 IF gp THEN green = 170 + zero ELSE green = zero
  111.                 IF rp THEN red = 170 + zero ELSE red = zero
  112.                 Kolor = _RGB(red, green, blue)
  113.             ELSEIF SMode = 13 THEN
  114.                 Kolor = ASC(LINE$, x + 1)
  115.             END IF
  116.             PSET (x, y), Kolor
  117.         NEXT
  118.     NEXT
  119.     _DEST d: _SOURCE s
  120.     StringToTile16 = tempimage
  121.  
  122.  
  123.  
  124.  
  125.  
  126. SUB paintImage (x, y, Border~&, destHandle&, imageHandle&)
  127.     d = _DEST: s = _SOURCE
  128.     _DEST destHandle&
  129.     PAINT (x, y), _RGB(119, 24, 49), Border~&
  130.     FOR y = 0 TO _HEIGHT(destHandle&)
  131.         FOR x = 0 TO _WIDTH(destHandle&)
  132.             _SOURCE destHandle&
  133.             IF POINT(x, y) = _RGB(119, 24, 49) THEN
  134.                 _SOURCE imageHandle&
  135.                 PSET (x, y), POINT(x MOD _WIDTH(imageHandle&), y MOD _HEIGHT(imageHandle&))
  136.             END IF
  137.         NEXT
  138.     NEXT
  139.     _DEST d: _SOURCE s
  140.  
  141.  
Further step SCREEN 32.
Title: [FIXED]: Help please an example taken from wiki is bugged! (Paint tiling)
Post by: FellippeHeitor on June 14, 2020, 12:34:20 am
Bringing back this old thread just to let you guys know that PAINT tiling has been added to QB64 for legacy SCREEN modes and is now available in the latest development build: https://www.qb64.org/portal/development-build/
Title: Re: [FIXED] Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on June 14, 2020, 05:59:48 pm
Cool!
Another step towards the future wonderful QB64 with more support of QB45.
Now it is wider the retrogaming perspective.
Title: Re: [FIXED] Help please an example taken from wiki is bugged! (Paint tiling)
Post by: TempodiBasic on June 15, 2020, 06:51:33 am
Here verifications with QB64x64 and QB64x32

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
great job!
Title: Re: [FIXED] Help please an example taken from wiki is bugged! (Paint tiling)
Post by: FellippeHeitor on June 15, 2020, 07:59:58 am
Thanks for testing it, TempodiBasic.

The latest patch was added by a github user called NEONTEC75.
Title: Re: [FIXED] Help please an example taken from wiki is bugged! (Paint tiling)
Post by: Petr on June 15, 2020, 12:19:06 pm
I'm very happy about that! Thank you for adding this functionality!