Qbasicnews.com
October 22, 2019, 03:49:03 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 ... 5 6 [7]
  Print  
Author Topic: Alternative GFXlib released  (Read 28867 times)
retsyo
Member
*
Posts: 73


« Reply #90 on: January 24, 2005, 11:15:42 PM »

Quote from: "lillo"

About GET arrays size: yes that's true, gfxlib always requires 1 byte per pixel for color depths <= 8. I can change that if it's really needed, but is it? Having always 1 byte per pixel really speed things up...

Do you mean that we can always use an array with width*height bytes to hold a width*height sprite safely? If so, it is great since I do not have to turn to QB manual to find the forumla everytime, and plz keep this feature.
What if we use the new lib that supports any color depth?
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #91 on: January 25, 2005, 03:29:54 AM »

Quote from: "Dr_Davenstein"
I don't think it matters either. The executable for Half-Life is like 930KB... 40KB is peanuts. Wink


That's just the EXE. Most of the GFX code and Game Engine is stored in DDL's.

So 40 kb is less than peanuts.  If people want to make GFX demos they'd have to use PTC,GL or DX directly.
;*)
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
lillo
Guru
**
Posts: 269


WWW
« Reply #92 on: January 25, 2005, 05:52:13 AM »

ok, MULTIKEY and GETMOUSE now in CVS.

retsyo: from the docs I'm writing, description of GET:
Code:
Use this function to save blocks of graphics so you can later use PUT to draw
them. The coordinates of the block are affected by the most recent WINDOW and
VIEW statements, and must be both inside the current clipping region set by
VIEW. The supplied array must be large enough to hold the block you're going
to save; the required array size depends on both the block size in pixels and
the current color depth. Use the following formula to compute the right size
in bytes:

For color depths 1, 2, 4 and 8:
size = 4 + (w * h)
For color depths 15 and 16:
size = 4 + (w * h * 2)
For color depths 24 and 32:
size = 4 + (w * h * 4)

Where w and h are the width and height of the graphics block you want to save.
Assuming you're working with INTEGER arrays, and as an INTEGER in FB is 4
bytes long, to save an 8bpp 32x32 block for example, you'll need an array of
(((4 + (w * h)) + 3) / 4) elements.


relsoft: actually I think this gfxlib is already far ahead of TinyPTC... Both in speed (at least for modes <32bit; 32bit mode is a bit faster in TinyPTC as it uses MMX color converters; wait until I write them too for gfxlib and the speed will be almost equal) and functionalities.  Cool
Logged

ngelo Mottola - EC++
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #93 on: January 25, 2005, 09:32:42 AM »

Quote from: "lillo"
na_th_an: about your supposed bug... that's not a bug at all. Mode 7 is supposed to be EGA, and in EGA you only have a 64 colors palette to play with: that means that you can assign any of these 64 colors to your base 16 colors by doing
Code:
PALETTE index, color

where index ranges 0-15 and color ranges 0-63. The EGA palette is a fixed one; I should write down in the docs what color corresponds to what. So OUT &h3C9 makes no sense here...


Nope, it does make sense. In VGA cards, you could access the DAC registers just fine in SCREEN 1, 2, 7 and 8.Also in SCREEN 9.

In SCREEN 1 and 2 you had 4 and 2 "colour slots", respectively. Each one of them could be assigned any of the 16 colours (using PALETTE). Each one of those 16 colours had its associated DAC registers that could be changed (using OUT...).

In SCREEN 7 and 8 you have 16 "colour slots". Each one of them could be assigned any of the 16 colours (using PALETTE). Each one of those 16 colours had its associated DAC registers as well.

In SCREEN 9 and SCREEN 0 you have 16 "colour slots". Each one of them could be assigned any of the 64 colours (using PALETTE). Each one of those 64 colours had its associated DAC registers that could be changed using OUT and stuff.

This info is somewhat hidden, though, but the DAC register work in those modes. Try it. The problem is that the OUTs don't affect the "colour slots", but the colours themselves. For example, in SCREEN 1, you can do this:

Code:
OUT &H3c8, 10
OUT &H3c9, 50
OUT &H3c9, 50
OUT &H3c9, 50


But that new light grey shade won't be visible until you assign colour #10 to one of the 4 colour slots with PALETTE:

Code:
PALETTE 1,10


Now colour #1 will be light grey.

The same you can do in SCREEN 7, 8 or 9. It's good practice to assign colours to colour slots before with just a simple:

Code:
FOR i% = 0 TO 15
   PALETTE i%, i%
NEXT i%


And now you can use the OUT stuff to change the colours directly.

I've used OUT to change SCREEN 7 the palette many times. Try it in QB to check it for yourself Smiley

Read this: http://faq.qbasicnews.com/?blast=PaletteInScreenNine

For SCREEN 1 you have 4 slots, 16 attributes. For SCREEN 2, 2 slots, 16 attributes. For SCREEN 7 and 8 the DACs are mapped in an odd way if you don't "rearrange stuff", I can't remember how right now.

EDIT:  I wrote this stuff some time ago for a tutorial. It has the mappings:

Quote
In SCREEN 1, the initial asociations are:
Code:

(colour set 1)
SLOT -> ATR
 0   -> 0
 1   -> 11
 2   -> 13
 3   -> 15

(colour set 2)
SLOT -> ATR
 0   -> 0
 1   -> 10
 2   -> 12
 3   -> 14

(colour set 3)
SLOT -> ATR
 0   -> 0
 1   -> 3
 2   -> 5
 3   -> 7

(colour set 4)
 SLOT -> ATR
 0   -> 0
 1   -> 2
 2   -> 4
 3   -> 6


In SCREEN 2 the initial associations are:

Code:

SLOT -> ATR
 0   -> 0
 1   -> 15


In SCREEN 7 and 8 the associations are:

Code:

SLOT -> ATR
 0   -> 0
 1   -> 1
 2   -> 2
 3   -> 3
 4   -> 4
 5   -> 5
 6   -> 6
 7   -> 7
 8   -> 16
 9   -> 17
10   -> 18
11   -> 19
12   -> 20
13   -> 21
14   -> 22
15   -> 23


In SCREEN 9  and 0 you have this:

Code:

SLOT -> ATR
 0   -> 0
 1   -> 1
 2   -> 2
 3   -> 3
 4   -> 4
 5   -> 5
 6   -> 20
 7   -> 7
 8   -> 56
 9   -> 57
10   -> 58
11   -> 59
12   -> 60
13   -> 61
14   -> 62
15   -> 63


To alter the DACs without problems it's good practice to assign the attributes just after your SCREEN statement:

Code:
FOR i% = 0 TO numSlots%-1
   PALETTE i%, i%
NEXT i%



Quote
About GET arrays size: yes that's true, gfxlib always requires 1 byte per pixel for color depths <= 8. I can change that if it's really needed, but is it? Having always 1 byte per pixel really speed things up...


That's why I called it "feature". You shoud just document it so people can port their stuff correctly. It's okay for me. One just has to make the arrays bigger Smiley

Quote
Now on to the suggestions:
1) PALETTE doesn't work in SCREEN 1. For SCREEN 1, you can use COLOR (as stated in the QB inline help) to switch the palette between the two CGA default palettes. See the QB COLOR statement details.


Wrong again. See above and try it in QB. Or check my old "StarOdds". It uses the trick all the time. If you want black, dark grey, dark green and light green in SCREEN 1 you just have to do:

Code:
PALETTE 0, 0
PALETTE 1, 8
PALETTE 2, 2
PALETTE 3, 10


Quote
2) You can always just do
Code:
PALETTE index, &hBBGGRR

where BB, GG and RR are the blue, green and red values ranging &h00 to &h3F (0-63)
BTW, in hi/truecolor modes you can always specify a color by using
Code:
COLOR &hRRGGBB, &hRRGGBB

(note the inverted order, RGB makes more sense to me) or by using the RGB function:
Code:
COLOR RGB(Red, Green, Blue), RGB(Red, Green, Blue)

as in Sterling's gfxlib.


Great to know. I did't think about that possibility. Thanks Smiley
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #94 on: January 25, 2005, 09:47:15 AM »

I can be really puzzling at times Tongue

Don't worry, I'll elaborate a complete document about all this and post it here.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #95 on: January 26, 2005, 01:39:57 AM »

will there be a linux port of this gfx lib?
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
lillo
Guru
**
Posts: 269


WWW
« Reply #96 on: January 26, 2005, 11:45:53 AM »

na_th_an: ok, rewrote palette handling to better emulate QB. Now in CVS.

dumbledore: an X11 driver is next on my ToDo list  :bounce:
Logged

ngelo Mottola - EC++
Pages: 1 ... 5 6 [7]
  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!