Qbasicnews.com

Full Version: Starting a fighting game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Quote:file is generating 8-bit RGB data, not 6-bit data. Windows PCX viewers will generally display that just fine. DOS programs generally won't. (And QB's PALETTE statement really doesn't like 8-bit RGB data.)

True. Look at this specs of the PCX format (from ZSoft, circa 1987):

Code:
VGA 256 Color Palette Information

ZSoft has recently added the capability to store palettes containing more
than 16 colors in the .PCX image file.  The 256 color palette is formatted
and treated the same as the 16 color palette, except that it is substantially
longer.  The palette (number of colors x 3 bytes in length) is appended to
the end of the .PCX file, and is preceded by a 12 decimal.  Since the VGA
device expects a palette value to be 0-63 instead of 0-255, you need to
divide the values read in the palette by 4.

So by default PCXs use 8 bits for each colour component. You just divide the values by four in your program when you are loading it and changing the DAC registers.

As the palette is appended at the end of your PCX file, a good way of reading the palette could be:

Code:
f% = FREEFILE
o$ = CHR$(0)    ' Trick to read just one byte :)

OPEN "myfile.pcx" FOR BINARY AS #f%
SEEK #f%, LOF(f%) - 767

FOR i% = 0 TO 255
   OUT &H3C8, i%
   FOR j% = 1 TO 3
      GET #f%, , o$
      OUT &H3C9, ASC(o$) \ 4
   NEXT j%
NEXT i%

CLOSE #f%

[Note that this may need a fix: I wrote it from the top of my head]
wiz so their is a way to read only one byte at a time. That's amazing. See we've all learned something today Big Grin .

What am I supposed to do with DEM8.BAS
I tried running it and yea it does run but how do I change my .pcx file. When I ran code nothing happened. No errors simply nothing.

Am I supposed to put my file name somewhere in the code. I'm a little lost. Just a little Tongue .

Wiz you mantioned backdrops what are they?
And btw how do I get transparency.
When I made my .pcx I made it in transparency and I actually put transparency into my pallate which the .pcx is saved in. So why doesn't it show up.

I still haven't gotton naruto.pcx to appear on the screen becuase of that pallate error, so I'm stuck for the moement.

Thanks for the helping me realize how to break up animation frames. It really made work so much faster.

I've gotten the keyhandler to work. Milo Sandleck is by far the simplest Keyhandler out there. No learning neccessory i love it.

I've designed what the ultimate program will look like so once I get those little sprites on screen I know exactly what I'm going to do and I should have a demo up first thing. Ofcoarse my friend still needs to figure out how to get rid of flickering in screen 13, becuase we've seen it done in code before without libaries. Also I've switched to QB 7.1 It's amazing. You can customize everything. I changed colors in every thing :king:

I'm waiting for a response on how to convert my .pcx

And do I still load it in the same way?

Code:
length = length + 1
DIM colorval AS LONG

FOR col = 0 TO 255
   GET #1, length + (col * 3), R%
   GET #1, length + (col * 3) + 1, G%
   GET #1, length + (col * 3) + 2, B%

   R% = R% AND 63
   G% = G% AND 63
   B% = B% AND 63

   colorval& = R% + (G% * 256) + (B% * 65536)

   PALETTE col, colorval&
NEXT

or should I try using what others suggested

Code:
length = length + 1
DIM colorval AS LONG

FOR col = 0 TO 255
   GET #1, length + (col * 3), R%
   GET #1, length + (col * 3) + 1, G%
   GET #1, length + (col * 3) + 2, B%

   R% = R% AND 63
   G% = G% AND 63
   B% = B% AND 63

  OUT &H3C8, col
  OUT &H3C9, R%
  OUT &H3C9, G%
  OUT &H3C9, B%
NEXT

If I got the logic of it right I guess that's how you'd do it?
I really have very little idea of the proccess so tell me before hand what mistakes I should avoid if I try this method.

PS: what's the difference between Screen 13 and Mode 13h?
PSS: Sorry for so many questions and comments that are all over the place. Just notice that every paragraph is a different thought in my head. That might help.
I said to run DEM8 from the DOS command-line and put the name of your file after it? Smile For example,


DEM8 myfile.pcx
kofman, I don't know if you missed my post Tongue

With those "AND 63" you are limiting to 6 bits, and that's _exactly_ what your VGA does. It will only read the 6 less significant bits, so doing AND 63 and not doing it is just the same.

Instead, you should divide by four, as I pointed out.

Also, as I explained, PALETTE is slower than the OUTs, 'cause it waits for a vsync (in most VGAs), so it means that you'll only be able to change a DAC register each 1/60 of a second.

To achieve transparency, you just make your blitter skip a certain colour. Most libs skip 0 'cause it is the fastest way (just an assembly jump). If you are gonna use GET/PUT, you'll need some masking. Masking is a technique which needs a mask for each sprite. I posted an extensive explanation on the technique before the forum hack - if you need it, I'll do it again, but it is not a good technique 'cause it is slow and needs as twice as memory as the transparency skipping technique.

The bad thing about the transparency skipping technique is that it is damn slow in pure QB, and you'll better use a LIB with a good transparent sprite blitter, or code it in assembly or C.

"Backdrops" are just the background graphics. Blame Capcom if I use that semi-inaccurate word Smile
The difference between "SCREEN 13" and "mode 13" is that "SCREEN 13" is just the QB statement to switch video modes to the one numbered 13. That mode has nothing to do with QB; it's a property of your video board. (And it's just basically a coincidence that the "13" of "SCREEN 13" actually refers to the video mode "13h". In "SCREEN 9", for example, that "9" has no relation to the actual number used by your video bios.)
How would I create transparency and reoganize the pallate?

Nathan you said I need a transparancy blitter. What exactly is a blitter? For example the color that I want to be used for transparany is 246.
How do I go about it. BTW since my pallate is so screwed up as it stands that 246 is actually a form of green. : )

If you have that masking tutorial saved somewhere that would be nice too : ). I really don't care how to do it.
A blitter is just the code that copies your sprites to screen or to a buffer. Most QB libs use #0 as it is faster to use that number. If you wanna code a blitter, it will be slow and unusable unless you have the computer that was inside the death star Tongue

To be able to use PUT and GET (which will be faster that your blitter) you'll have to do masking. I'll try to put together a tut tomorrow.

Why don't you use a lib? they fit in a diskette with QB45 so...
Don't Like libs too many problems with them. I'll try to be as lib free as possible.
Like you want, but the only "problem" you'll have with i.e. DQB is doing QB /LDQB.QLB instead of doing QB /L ... Not much problem IMHO. Anyhow, I'll write that tutorial.
you'd get a bigger mess of problems trying to spagetti code all these routines in "pure" qb (if such a thing exists).
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16