Zorba the Hutt (zorbathut) wrote,
Zorba the Hutt

  • Mood:

What I'm Doing At Work

So first I see a line like:

p.addGifPixelTest( 0, 1, Packet::ATM_GREATER, 1, Packet::ATP_KEEP, 0, 0, 1, Packet::DTM_PASS );

I go look up the function, which requires doing a quick text search. I find:

void addGifPixelTest( int context, int alphaTestEnable, int alphaTestMethod, int alphaRef, int alphaFailProcess, int destAlphaTestEnable, int destAlphaTestMode, int depthTestEnable, int depthTestMethod ) { addToGif( 0x47 + context, ( alphaTestEnable ) | ( alphaTestMethod << 1 ) | ( alphaRef << 4 ) | ( alphaFailProcess << 12 ) | ( destAlphaTestEnable << 14 ) | ( destAlphaTestMode << 15 ) | (depthTestEnable << 16 ) | ( depthTestMethod << 17 ) ); }

I already know (from having done this many times before) that addToGif, in the current function mode, sets the *first* parameter (as a register) to the value of the *second* parameter.

So, I go to the Graphics Subsystem manual, page 151, and look up 0x47. 0x47 is apparently the token TEST_1. Unfortunately, it doesn't provide a page number, so I go to the middle of the token descriptions - they're sorted alphabetically - and find TEST_1 on page 116.

Now I have a chart of what all the bits mean, which would probably be more help if I could map instantly in my brain. I know that the first "context" parameter is always 0 for some reason (I'm presuming there are two symmetric systems here, but I don't know that for certain) and that it doesn't really have a lot to do with what it's doing. It takes some work, but I puzzle out the rest. alphaTestEnable is, coincidentally, the Alpha Test Enable flag. Since it's being called with 1, it's turning the Alpha Test on. Unfortunately Page 116 doesn't mention a whole lot about what exactly the Alpha Test really does, so I note that there's a chapter heading (3.7) and I go to it. Naturally it doesn't include a page number, and chapter headings are *not* on the tops of the pages.

Digging around for a minute finds Chapter 3.7 on Page 60, and it's about five pages long.

The first thing I find is that 3.7 doesn't actually deal with the Alpha Test, it actually deals with Pixel Tests, and Alpha Test is about a page further down, at section 3.7.2. Okay. I can deal. Referring back and forth I discover that the "1" does indeed mean alpha testing is enabled, and Packet::ATM_GREATER indicates that "Pixels greater than AREF pass". Unfortunately the next thing 3.7.2 talks about isn't AREF, but is instead AFAIL, so it's back to Page 116 for me.

Page 116 points out that AREF is bits 4 to 11, and looking up at my original function lets me observe that the data in that field is alphaRef, and looking up at the *call* indicates that alphaRef is, in fact, 1.

Okay. Pixels greater than 1 pass.

Next section is, in fact, AFAIL, and apparently Packet::ATP_KEEP refers to "KEEP", or "Neither frame buffer nor Z buffer is updated."

Back to page 60.

No, wait. 61.

All Page 61 says is that when AFAIL is set to KEEP, all of RGB, A, and Z are Controlled. It has a curious lack of explanation on what "Controlled" means, but eventually I decide that it basically means "won't be changed".

At this point I realize that it would help a lot if I knew whether an alpha of 0 is fully transparent or fully opaque.

However, the map image going *in* is mostly fully opaque, and the sections that are fully opaque don't seem to be being drawn, so I'm going to assume that 0 is fully opaque.

Luckily, the next few parameters seem easy. destAlphaTestEnable is 0, so I skip it. So is depthTestEnable. However, depthTestMethod isn't, so I guess I'd better look it up. I follow a hunch and determine that the Depth Test information is on page 62, in section 3.7.4 (3.7.3 is Destination Alpha Test, and I scan it quickly to make sure I'm not missing anything - I'm not.) The available values for the depth test are NEVER, ALWAYS, GEQUAL, and GREATER - however, the value that's being sent is DTM_PASS.


However, a search for DTM_PASS assures me that DTM_PASS is 1, as is ALWAYS. (You can never assume what's going on. AI_ZERO, for example, is - rather paradoxically - equal to 2.)

So now I know what it's doing.

It's dumping all the fully opaque pixels.

One line down.

Four pages to go.
  • Post a new comment


    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.