DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
Page 1 of 1
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Thu Apr 24, 2008 5:27 pm
   Subject: [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

This is a somewhat generic coding question, and may also apply to the Borland and 4GW versions.

In id_vl.cpp's VL_MemToScreenScaledCoord function, I would like to check which particular VGA graphic is being processed to decide what to do. I assume the VGA picture information is passed on to this function via the "byte *source" parameter in the first void line:

::: CODE :::
void VL_MemToScreenScaledCoord (byte *source, int width, int height, int destx, int desty)
{
   switch (graphicnums)
   {
       case 10:
       {       
          bla bla bla bla
        }
          break;
       


What should I put in the switch (red)? Graphicnums by itself fails on compiling, and I get this error message:
In function `void VL_MemToScreenScaledCoord(byte*, int, int, int, int)': expected primary-expression before ')' token

In this example, I want to do bla bla bla bla if the C_OPTIONSPIC in gfxv_wl6.h is being processed.

Thanks,
Andy

Edit: changed thread subject line


Last edited by Andy_Nonymous on Sat Apr 26, 2008 1:24 pm; edited 1 time in total
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Thu Apr 24, 2008 8:44 pm
   Subject: [SDL Help] Want to check vga gfx lump before processing
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Couldn't sleep... I tried Switch (*source), and it compiles!

However, the case numbers do not correspond exactly with the pictures for some reason. For instance, episode 1 and episode 2 pics are at 14 and 15 respectively (30 and 31 in gfxv_wl6.h). So it would seem that the bj baby pic should be at case 3 (19 in gfxv_wl6.h).
Not so!

Looking at id_ca.cpp, source seems to be a lot more complicated than graphicnums:
::: CODE :::
if (compressed<=BUFFERSIZE)
    {
        read(grhandle,bufferseg,compressed);
        source = bufferseg;
    }
    else
    {
        source = (int32_t *) malloc(compressed);
        CHECKMALLOCRESULT(source);
        read(grhandle,source,compressed);


Maybe what I'm trying to do is impossible? I hope not...

Andy
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Fri Apr 25, 2008 1:05 pm
   Subject: Re: [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, what you are trying to do doesn't make much sense. VL_MemToScreenScaledCoord is a low level function which just gets a pointer to image data (i.e. pixel colors) and draws it at the given positions. Nobody tells this function, what graphic number or whatever it is painting.

What exactly do you want to do? If you want to do something different, when the options picture should be displayed, you should have a look at WL_MENU:620 (in DrawMainMenu). There VWB_DrawPic is called with a position and the chunknum.
If you REALLY want to do such a switch, you should do it in VWB_DrawPic over picnum. But I cannot think of a reason, why you would want to manipulate a picture number in the drawing routine...

_________________
Life is an awful game, but the graphics resolution rocks ;D
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Fri Apr 25, 2008 1:55 pm
   Subject: [SDL Help] Want to check vga gfx lump before processing
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ripper,

OK, so that would explain my lack of success! Laughing

What I am trying to do is to manipulate the ScaleFactor, depending on which image is being displayed. Some images are "hi-res" (double-sized) while others are regular/normal sized. All should fit in the normal Wolfenstein helpart/menu/statusbar scheme despite their different resolutions under the covers. Much of what I want to do is currently working; there are some "normal" images remaining that are displaying too small (half-sized).

Another thing I was considering was to duplicate VL_MemToScreenScaledCoord (for the hi-res mode) and call one or the other from "higher up", based on the picnum. I have no idea if this is the best way to go; my Wolf programming method tends to be to keep experimenting until I get it to work...

Any suggestions?

Andy
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 21 Sep 2017

Topics: 22
Posts: 1281
Location: Rauma - Finland
finland.gif

PostPosted: Fri Apr 25, 2008 2:06 pm
   Subject: Re: [SDL Help] Want to check vga gfx lump before processing
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Andy_Nonymous wrote:
I have no idea if this is the best way to go; my Wolf programming method tends to be to keep experimenting until I get it to work...


There's nothing wrong with experimenting things, it's a good way to learn what not to do, and if you get it right that helps too. When someone corrects you, you most likely remember that and thus learn something new. I've learned very similarly on many occasions.

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Fri Apr 25, 2008 5:23 pm
   Subject: [SDL Help] Want to check vga gfx lump before processing
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Here is a solution. Note that it will only work with a fixed 640x400 screen (thanks to AlumiuN for the suggestion), and this does not affect any of the "Latch" items (status bar numbers/pics, getpsyched).

In ID_VL.CPP make a copy of the (first of two functions called)
void VL_MemToScreenScaledCoord (byte *source, int width, int height, int destx, int desty)

call it VL_MemToScreenScaledCoord2 and change all instances of ScaleFactor to ScaleFactor/2:
::: CODE :::
// New function
void VL_MemToScreenScaledCoord2 (byte *source, int width, int height, int destx, int desty)
{
    assert(destx >= 0 && destx + width * scaleFactor/2 <= screenWidth
            && desty >= 0 && desty + height * scaleFactor/2 <= screenHeight
            && "VL_MemToScreenScaledCoord: Destination rectangle out of bounds!");

    VL_LockSurface(curSurface);
    byte *vbuf = (byte *) curSurface->pixels;
    for(int j=0,scj=0; j<height; j++, scj+=scaleFactor/2)
    {
        for(int i=0,sci=0; i<width; i++, sci+=scaleFactor/2)
        {
            byte col = source[(j*(width>>2)+(i>>2))+(i&3)*(width>>2)*height];
            for(unsigned m=0; m<scaleFactor/2; m++)
            {
                for(unsigned n=0; n<scaleFactor/2; n++)
                {
                    vbuf[(scj+m+desty)*curPitch+sci+n+destx] = col;
                }
            }
        }
    }
    VL_UnlockSurface(curSurface);
}

Also will need to add a void line for this in ID_VL.H:
::: CODE :::
void VL_MemToScreenScaledCoord  (byte *source, int width, int height, int scx, int scy);
void VL_MemToScreenScaledCoord2 (byte *source, int width, int height, int scx, int scy);
void VL_MemToScreenScaledCoord  (byte *source, int origwidth, int origheight, int srcx, int srcy,

In ID_VL.H make a copy of VL_MemToScreen called VL_MemToScreen2 that calls the VL_MemToScreenScaledCoord2 function instead of VL_MemToScreenScaledCoord:
::: CODE :::
// New function
void inline VL_MemToScreen2 (byte *source, int width, int height, int x, int y)
{
    VL_MemToScreenScaledCoord2(source, width, height,
        scaleFactor*x, scaleFactor*y);
}

In ID_VH.CPP, change the VWB_DrawPic function to select the desired graphics chunks:
::: CODE :::
void VWB_DrawPic (int x, int y, int chunknum)
{
   int   picnum = chunknum - STARTPICS;
   unsigned width,height;

   x &= ~7;

   width = pictable[picnum].width;
   height = pictable[picnum].height;
   
   switch (picnum) //  MemToScreen2 for hi-res pics
   {
      case 16:     // baby mode
      case 17:     // don't hurt me
      case 18:     // bring 'em on
      case 19:     // death incarnate
         VL_MemToScreen2 (grsegs[chunknum],width,height,x,y);
         break;   
      default:   //  normal pics
         VL_MemToScreen (grsegs[chunknum],width,height,x,y);
    }   

}

This will let you selectively use hi-res VGA pictures when they are called by VWB_DrawPic. Note that picnum is chunknum-3.

Thanks all for your help and encouragement! Pizza

Andy
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Fri Apr 25, 2008 5:33 pm
   Subject: Re: [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

OK, I understand. I don't know what's the best solution, but I would try the way with the switch in VWB_DrawPic. The default case would just call VL_MemToScreenScaledCoord and the special cases would call... eehm... either a modified duplicate of VL_MemToScreenScaledCoord without the scaling or perhaps you could use VL_MemToLatch with curSurface as the destSurface parameter.

Just try it out and play around a bit with it. Keep in mind, that you should become familiar with using a debugger to see, why things don't work out the way you think they should. This also helps a lot understanding what is happening. For debugging you should let the debugger start Wolf4SDL with the "--windowed" parameter. Note, that you won't see changes on screen immediately because of the double buffering.

Which development environment are you using again?

_________________
Life is an awful game, but the graphics resolution rocks ;D
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Fri Apr 25, 2008 6:11 pm
   Subject: [SDL Help] Want to check vga gfx lump before processing
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ripper,

I'm using Dev-C++ on Win98. Yeah, I really should start using the debugger.

Andy
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Sat Apr 26, 2008 1:10 pm
   Subject: Re: [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

*lol* I didn't notice the post you wrote right before my last one!
Using scaleFactor/2 makes more sense than directly painting it, as I thought at first, so good work!
But I would use the enum constants from the gfx_XXX.h file. Just switch over picnum+3 instead of picnum and you can write e.g. "case C_BABYMODEPIC:" ;D
This will save you much trouble if you change any graphics later on.

_________________
Life is an awful game, but the graphics resolution rocks ;D
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 2:51 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Apr 27, 2008 2:30 am
   Subject: Re: [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

That's so much more confusing than I had planned out for my mod, but I suppose you're using selectively hi-res images, so that's OK. Smile
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Announcement: Wolf3d & Spear of Destiny Shareware SDL Downloads
Author: BrotherTank
10 13000 Tue Aug 24, 2010 10:18 am
dcbasic View latest post
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 17023 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts Remaking released mod into SDL
Author: Dean
14 3033 Thu Aug 14, 2008 4:58 pm
Dean View latest post
No new posts [Help] Gun Bobbing in SDL
Author: RichterBelmont12
8 2130 Wed Jul 23, 2008 6:37 pm
Tricob View latest post
No new posts [Help] Problem with Checkweaponchange function (wolf4sdl)
Author: Mortimer
4 2281 Sat May 17, 2008 11:26 am
Mortimer View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group