Пример #1
0
void Missile::Update(DWORD)
{
    // TODO
    center.x = center.x + LONG(speed*sin(theta*D2R));
    center.y = center.y - LONG(speed*cos(theta*D2R));
}
Пример #2
0
static void
vesalinear(VGAscr *scr, int _1, int _2)
{
	int i, mode, size, havesize;
	uint8_t *p;
	uint32_t paddr;
	Pcidev *pci;

	if(hardscreen) {
		scr->vaddr = 0;
		scr->paddr = scr->apsize = 0;
		return;
	}

	vbecheck();
	mode = vbegetmode();
	/*
	 * bochs loses the top bits - cannot use this
	if((mode&(1<<14)) == 0)
		error("not in linear graphics mode");
	 */
	mode &= 0x3FFF;
	p = vbemodeinfo(mode);
	if(!(WORD(p+0) & (1<<4)))
		error("not in VESA graphics mode");
	if(!(WORD(p+0) & (1<<7)))
		error("not in linear graphics mode");

	paddr = LONG(p+40);
	size = WORD(p+20)*WORD(p+16);
	size = ROUNDUP(size, PGSZ);

	/*
	 * figure out max size of memory so that we have
	 * enough if the screen is resized.
	 */
	pci = nil;
	havesize = 0;
	while(!havesize && (pci = pcimatch(pci, 0, 0)) != nil){
		if(pci->ccrb != Pcibcdisp)
			continue;
		for(i=0; i<nelem(pci->mem); i++)
			if(paddr == (pci->mem[i].bar&~0x0F)){
				if(pci->mem[i].size > size)
					size = pci->mem[i].size;
				havesize = 1;
				break;
			}
	}

	/* no pci - heuristic guess */
	if (!havesize)
		if(size < 4*1024*1024)
			size = 4*1024*1024;
		else
			size = ROUND(size, 1024*1024);
	if(size > 16*1024*1024)		/* arbitrary */
		size = 16*1024*1024;

	vgalinearaddr(scr, paddr, size);
	if(scr->apsize)
		addvgaseg("vesascreen", scr->paddr, scr->apsize);

	if(Usesoftscreen){
		hardscreen = scr->vaddr;
		scr->vaddr = 0;
		scr->paddr = scr->apsize = 0;
	}
}
Пример #3
0
//
// CheckIWAD
//
// Tries to find an IWAD from a set of know IWAD names, and checks the first
// one found's contents to determine whether registered/commercial features
// should be executed (notably loading PWAD's).
//
static bool CheckIWAD (std::string suggestion, std::string &titlestring)
{
	static const char *doomwadnames[] =
	{
		"doom2f.wad",
		"doom2.wad",
		"plutonia.wad",
		"tnt.wad",
		"doomu.wad", // Hack from original Linux version. Not necessary, but I threw it in anyway.
		"doom.wad",
		"doom1.wad",
		"freedoom.wad",
		"freedm.wad",
		"chex.wad",		// [ML] 1/7/10: Hello Chex Quest!
		NULL
	};

	std::string iwad;
	std::string iwad_file;
	int i;

	if(suggestion.length())
	{
		std::string found = BaseFileSearch(suggestion, ".WAD");

		if(found.length())
			iwad = found;
		else
		{
			if(M_FileExists(suggestion.c_str()))
				iwad = suggestion;
		}
		/*	[ML] Removed 1/13/10: we can trust the user to provide an iwad
		if(iwad.length())
		{
			FILE *f;

			if ( (f = fopen (iwad.c_str(), "rb")) )
			{
				wadinfo_t header;
				fread (&header, sizeof(header), 1, f);
				header.identification = LONG(header.identification);
				if (header.identification != IWAD_ID)
				{
					if(header.identification == PWAD_ID)
					{
						Printf(PRINT_HIGH, "Suggested file is a PWAD, not an IWAD: %s \n", iwad.c_str());
					}
					else
					{
						Printf(PRINT_HIGH, "Suggested file is not an IWAD: %s \n", iwad.c_str());
					}
					iwad = "";
				}
				fclose(f);
			}
		}
		*/
	}

	if(!iwad.length())
	{
		// Search for a pre-defined IWAD from the list above
		for (i = 0; doomwadnames[i]; i++)
		{
			std::string found = BaseFileSearch(doomwadnames[i]);

			if(found.length())
			{
				iwad = found;
				break;
			}
		}
	}

	// Now scan the contents of the IWAD to determine which one it is
	if (iwad.length())
	{
#define NUM_CHECKLUMPS 9
		static const char checklumps[NUM_CHECKLUMPS][8] = {
			"E1M1", "E2M1", "E4M1", "MAP01",
			{ 'A','N','I','M','D','E','F','S'},
			"FINAL2", "REDTNT2", "CAMO1",
			{ 'E','X','T','E','N','D','E','D'}
		};
		int lumpsfound[NUM_CHECKLUMPS];
		wadinfo_t header;
		FILE *f;
		M_ExtractFileName(iwad,iwad_file);

		memset (lumpsfound, 0, sizeof(lumpsfound));
		if ( (f = fopen (iwad.c_str(), "rb")) )
		{
			fread (&header, sizeof(header), 1, f);
			header.identification = LONG(header.identification);
			if (header.identification == IWAD_ID ||
				header.identification == PWAD_ID)
			{
				header.numlumps = LONG(header.numlumps);
				if (0 == fseek (f, LONG(header.infotableofs), SEEK_SET))
				{
					for (i = 0; i < header.numlumps; i++)
					{
						filelump_t lump;
						int j;

						if (0 == fread (&lump, sizeof(lump), 1, f))
							break;
						for (j = 0; j < NUM_CHECKLUMPS; j++)
							if (!strnicmp (lump.name, checklumps[j], 8))
								lumpsfound[j]++;
					}
				}
			}
			fclose (f);
		}

		gamemode = undetermined;

		if (lumpsfound[3])
		{
			gamemode = commercial;
			gameinfo = CommercialGameInfo;
			if (lumpsfound[6])
			{
				gamemission = pack_tnt;
				titlestring = "DOOM 2: TNT - Evilution";
			}
			else if (lumpsfound[7])
			{
				gamemission = pack_plut;
				titlestring = "DOOM 2: Plutonia Experiment";
			}
			else
			{
				gamemission = doom2;
				titlestring = "DOOM 2: Hell on Earth";
			}
		}
		else if (lumpsfound[0])
		{
			gamemission = doom;
			if (lumpsfound[1])
			{
				if (lumpsfound[2])
				{
					if (!StdStringCompare(iwad_file,"chex.wad",true))	// [ML] 1/7/10: HACK - There's no unique lumps in the chex quest
					{								// iwad.  It's ultimate doom with their stuff replacing most things.
						gamemission = chex;
						gamemode = retail_chex;
						gameinfo = RetailGameInfo;
						titlestring = "Chex Quest";
					}
					else
					{
						gamemode = retail;
						gameinfo = RetailGameInfo;
						titlestring = "The Ultimate DOOM";
					}
				}
				else
				{
					gamemode = registered;
					gameinfo = RegisteredGameInfo;
					titlestring = "DOOM Registered";
				}
			}
			else
			{
				gamemode = shareware;
				gameinfo = SharewareGameInfo;
				titlestring = "DOOM Shareware";
			}
		}
	}

	if (gamemode == undetermined)
	{
		gameinfo = SharewareGameInfo;
	}

	if (iwad.length())
		wadfiles.push_back(iwad);

	return iwad.length() ? true : false;
}
Пример #4
0
HairGuides *_GenerateFn(BaseDocument *doc, BaseList2D *op, HairObject *hair, BaseThread *thd, VolumeData *vd, LONG pass, void *data)
{
	HairGrassObject *grass=(HairGrassObject*)op->GetNodeData();
	BaseContainer *bc=op->GetDataInstance();
	HairGuides *hairs=NULL;

	switch (pass)
	{
	case HAIR_GENERATE_PASS_INIT:
	{
		grass->m_pPoly=(PolygonObject*)bc->GetLink(HAIR_GRASS_LINK,doc,Opolygon);
		if (!grass->m_pPoly) return NULL;

		grass->m_Count=bc->GetLong(HAIR_GRASS_COUNT);
		grass->m_Segments=bc->GetLong(HAIR_GRASS_SEGMENTS);
		grass->m_Length=bc->GetReal(HAIR_GRASS_LENGTH);
		grass->m_LengthVar=bc->GetReal(HAIR_GRASS_LENGTH);
		grass->m_Noise=bc->GetReal(HAIR_GRASS_NOISE);
		
		BaseContainer *hbc=hair->GetDataInstance();

		hbc->SetLink(HAIRSTYLE_LINK,grass->m_pPoly);
		hbc->SetLong(HAIRSTYLE_FUR_COUNT,grass->m_Count);

		break;
	}
	case HAIR_GENERATE_PASS_BUILD:
		if (bc->GetBool(HAIR_GRASS_GENERATE))
		{
			hairs=HairGuides::Alloc(grass->m_Count,grass->m_Segments);
			if (hairs) hair->SetGuides(hairs,FALSE);
			hairs=hair->GetGuides();

			if (hairs)
			{
				Vector *pnts=hairs->GetPoints(),n(DC),r(DC);
				LONG i,scnt=(grass->m_Segments+1),l=0,ply;
				//const Vector *padr=grass->m_pPoly->GetPointR();
				const CPolygon *vadr=grass->m_pPoly->GetPolygonR();
				LONG vcnt=grass->m_pPoly->GetPolygonCount();
				Real s,t;
				HairRootData hroot;
					
				hroot.m_Type=HAIR_ROOT_TYPE_POLY;

				grass->m_Rnd.Init(4729848);

				for (i=0;i<grass->m_Count;i++)
				{
					ply=LONG(grass->m_Rnd.Get01()*Real(vcnt-1));

					if (vadr[ply].c==vadr[ply].d)
					{
						do { s=grass->m_Rnd.Get01(),t=grass->m_Rnd.Get01(); }
						while ((s+t)>1.0);
					}
					else
					{
						s=grass->m_Rnd.Get01(),t=grass->m_Rnd.Get01();
					}

					hroot.m_ID=ply;
					hroot.m_S=s;
					hroot.m_T=t;

					hairs->SetRoot(0,hroot,FALSE);
					hairs->GetRootData(0,&r,&n,NULL,FALSE);
						
					Real len=grass->m_Length+grass->m_LengthVar*grass->m_Rnd.Get11();
					Vector dn=n;
					Matrix axis;

					hairs->GetRootAxis(0,axis,FALSE,FALSE);

					dn.x+=grass->m_Noise*SNoise(Vector(ply,s,t));
					dn.y+=grass->m_Noise*SNoise(Vector(i,ply,t));
					dn.z+=grass->m_Noise*SNoise(Vector(ply,s,i));

					dn=(!dn)*len;

					for (l=0;l<scnt;l++)
					{
						pnts[i*scnt+l]=r+dn*Real(l)/Real(scnt-1);
					}
				}
			}
		}
		else
			hairs=HairGuides::Alloc(1,grass->m_Segments);

		break;
	case HAIR_GENERATE_PASS_FREE:
		break;
	}

	return hairs;
}
Пример #5
0
void W_AddFile (char *filename)
{
    wadinfo_t           header;
    lumpinfo_t*         lump_p;
    unsigned            i;
    int                 handle;
    int                 length;
    int                 startlump;
    filelump_t*         fileinfo;
    filelump_t          singleinfo;
    int                 storehandle;

    // open the file and add to directory

    // handle reload indicator.
    if (filename[0] == '~')
    {
        filename++;
        reloadname = filename;
        reloadlump = numlumps;
    }

    if ( (handle = open (filename,O_RDONLY | O_BINARY)) == -1)
    {
        printf (" couldn't open %s\n",filename);
        return;
    }

    printf (" adding %s\n",filename);
    startlump = numlumps;

    if (strcmpi (filename+strlen(filename)-3 , "wad" ) )
    {
        // single lump file
        fileinfo = &singleinfo;
        singleinfo.filepos = 0;
        singleinfo.size = LONG(filelength(handle));
        ExtractFileBase (filename, singleinfo.name);
        numlumps++;
    }
    else
    {
        // WAD file
        read (handle, &header, sizeof(header));
        if (strncmp(header.identification,"IWAD",4))
        {
            // Homebrew levels?
            if (strncmp(header.identification,"PWAD",4))
            {
                I_Error ("Wad file %s doesn't have IWAD "
                         "or PWAD id\n", filename);
            }

            // ???modifiedgame = true;
        }
        header.numlumps = LONG(header.numlumps);
        header.infotableofs = LONG(header.infotableofs);
        length = header.numlumps*sizeof(filelump_t);
        fileinfo = alloca (length);
        lseek (handle, header.infotableofs, SEEK_SET);
        read (handle, fileinfo, length);
        numlumps += header.numlumps;
    }


    // Fill in lumpinfo
    lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));

    if (!lumpinfo)
        I_Error ("Couldn't realloc lumpinfo");

    lump_p = &lumpinfo[startlump];

    storehandle = reloadname ? -1 : handle;

    for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++)
    {
        lump_p->handle = storehandle;
        lump_p->position = LONG(fileinfo->filepos);
        lump_p->size = LONG(fileinfo->size);
        strncpy (lump_p->name, fileinfo->name, 8);
    }

    if (reloadname)
        close (handle);
}
Пример #6
0
//
// CheckIWAD
//
// Verify a file is indeed tagged as an IWAD
// Scan its lumps for levelnames and return gamemode as indicated
// Detect missing wolf levels in DOOM II
//
// The filename to check is passed in iwadname, the gamemode detected is
// returned in gmode, hassec returns the presence of secret levels
//
// jff 4/19/98 Add routine to test IWAD for validity and determine
// the gamemode from it. Also note if DOOM II, whether secret levels exist
// CPhipps - const char* for iwadname, made static
static void CheckIWAD(const char *iwadname,GameMode_t *gmode,boolean *hassec)
{
  int read_iwad = 0;
  FILE* fp = fopen(iwadname, "rb");

  if (fp != NULL)
     read_iwad = 1;

  fclose(fp);

  if ( read_iwad )
  {
    int ud=0,rg=0,sw=0,cm=0,sc=0;

    // Identify IWAD correctly
    if ((fp = fopen(iwadname, "rb")))
    {
      wadinfo_t header;

      // read IWAD header
      if (fread(&header, sizeof(header), 1, fp) == 1 && !strncmp(header.identification, "IWAD", 4))
      {
        size_t length;
        filelump_t *fileinfo;

        // read IWAD directory
        header.numlumps = LONG(header.numlumps);
        header.infotableofs = LONG(header.infotableofs);
        length = header.numlumps;
        fileinfo = malloc(length*sizeof(filelump_t));
        if (fseek (fp, header.infotableofs, SEEK_SET) ||
            fread (fileinfo, sizeof(filelump_t), length, fp) != length ||
            fclose(fp))
          I_Error("CheckIWAD: failed to read directory %s",iwadname);

        // scan directory for levelname lumps
        while (length--)
          if (fileinfo[length].name[0] == 'E' &&
              fileinfo[length].name[2] == 'M' &&
              fileinfo[length].name[4] == 0)
          {
            if (fileinfo[length].name[1] == '4')
              ++ud;
            else if (fileinfo[length].name[1] == '3')
              ++rg;
            else if (fileinfo[length].name[1] == '2')
              ++rg;
            else if (fileinfo[length].name[1] == '1')
              ++sw;
          }
          else if (fileinfo[length].name[0] == 'M' &&
                    fileinfo[length].name[1] == 'A' &&
                    fileinfo[length].name[2] == 'P' &&
                    fileinfo[length].name[5] == 0)
          {
            ++cm;
            if (fileinfo[length].name[3] == '3')
              if (fileinfo[length].name[4] == '1' ||
                  fileinfo[length].name[4] == '2')
                ++sc;
          }

        free(fileinfo);
      }
      else // missing IWAD tag in header
        I_Error("CheckIWAD: IWAD tag %s not present", iwadname);
    }
    else // error from open call
      I_Error("CheckIWAD: Can't open IWAD %s", iwadname);

    // Determine game mode from levels present
    // Must be a full set for whichever mode is present
    // Lack of wolf-3d levels also detected here

    *gmode = indetermined;
    *hassec = FALSE;
    if (cm>=30)
    {
      *gmode = commercial;
      *hassec = sc>=2;
    }
    else if (ud>=9)
      *gmode = retail;
    else if (rg>=18)
      *gmode = registered;
    else if (sw>=9)
      *gmode = shareware;
  }
  else // error from access call
    I_Error("CheckIWAD: IWAD %s not readable", iwadname);
}
Пример #7
0
wad_file_t *W_AddFile (char *filename)
{
    wadinfo_t header;
    lumpinfo_t *lump_p;
    unsigned int i;
    wad_file_t *wad_file;
    int length;
    int startlump;
    filelump_t *fileinfo;
    filelump_t *filerover;

    // open the file and add to directory

    wad_file = W_OpenFile(filename);

    if (wad_file == NULL)
        return NULL;

    startlump = numlumps;

    if (strcasecmp(filename + strlen(filename) - 3, "wad"))
    {
        // single lump file

        // fraggle: Swap the filepos and size here.  The WAD directory
        // parsing code expects a little-endian directory, so will swap
        // them back.  Effectively we're constructing a "fake WAD directory"
        // here, as it would appear on disk.

        fileinfo = (filelump_t *)Z_Malloc(sizeof(filelump_t), PU_STATIC, 0);
        fileinfo->filepos = LONG(0);
        fileinfo->size = LONG(wad_file->length);

        // Name the lump after the base of the filename (without the
        // extension).

        ExtractFileBase(filename, fileinfo->name);
        numlumps++;
    }
    else
    {
        // WAD file
        W_Read(wad_file, 0, &header, sizeof(header));

        if (strncmp(header.identification, "IWAD", 4))
        {
            // Homebrew levels?
            if (strncmp(header.identification, "PWAD", 4))
                I_Error("Wad file %s doesn't have IWAD or PWAD id\n", filename);
        }

        header.numlumps = LONG(header.numlumps);
        header.infotableofs = LONG(header.infotableofs);
        length = header.numlumps * sizeof(filelump_t);
        fileinfo = (filelump_t *)Z_Malloc(length, PU_STATIC, 0);

        W_Read(wad_file, header.infotableofs, fileinfo, length);
        numlumps += header.numlumps;
    }

    // Fill in lumpinfo
    lumpinfo = (lumpinfo_t *)realloc(lumpinfo, numlumps * sizeof(lumpinfo_t));

    if (lumpinfo == NULL)
        I_Error("Couldn't realloc lumpinfo");

    lump_p = &lumpinfo[startlump];

    filerover = fileinfo;

    for (i = startlump; i < numlumps; ++i)
    {
        lump_p->wad_file = wad_file;
        lump_p->position = LONG(filerover->filepos);
        lump_p->size = LONG(filerover->size);
        lump_p->cache = NULL;
        strncpy(lump_p->name, filerover->name, 8);

        ++lump_p;
        ++filerover;
    }

    Z_Free(fileinfo);

    if (lumphash != NULL)
    {
        Z_Free(lumphash);
        lumphash = NULL;
    }

    return wad_file;
}
Пример #8
0
cglApp::cglApp(int nW, int nH, void* hInst, int nCmdShow) 
  : m_hWnd(NULL)
  , m_hInstance(hInst)
  , m_nClearColor(0xFF007F00)
  , m_pD3D(NULL)
  , m_nFrameCount(0)
  , m_rPrevTime(0.0f)
{
  // Register window class
  WNDCLASS wndClass;
  wndClass.style          = 0;
  wndClass.lpfnWndProc    = D3DBaseAppCallback;
  wndClass.cbClsExtra     = 0;
  wndClass.cbWndExtra     = 4;
  wndClass.hInstance      = HINSTANCE(hInst);
  wndClass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
  wndClass.hCursor        = LoadCursor(NULL, IDC_ARROW);
  wndClass.hbrBackground  = HBRUSH(GetStockObject(WHITE_BRUSH));
  wndClass.lpszMenuName   = NULL;
  wndClass.lpszClassName  = s_windowClassName;
  RegisterClass(&wndClass);

  // Adjust window in regard to client area nW x nH
  int  nStyle = WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
  RECT rRect;
  SetRect(&rRect, 0, 0, nW, nH);
  AdjustWindowRect(&rRect, nStyle, TRUE);
  
  // Create main window
  m_hWnd = NULL;
  m_hWnd = (void*)CreateWindow(s_windowClassName, getWindowText(), nStyle,
                               CW_USEDEFAULT, CW_USEDEFAULT, 
                               (rRect.right - rRect.left), (rRect.bottom - rRect.top),
                               NULL, NULL, HINSTANCE(hInst), NULL);
  if (m_hWnd == NULL)
    return;
    
  // Set pointer
  SetWindowLong(HWND(m_hWnd), 0, LONG(this));

  // Show window
  ShowWindow(HWND(m_hWnd), nCmdShow);
  UpdateWindow(HWND(m_hWnd));
  
  // We need to determine the BPP of desktop
  HDC hDC = GetDC(HWND(m_hWnd));            // Get DC of desktop
  int nBPP = GetDeviceCaps(hDC, BITSPIXEL); // Retrieve BPP
  ReleaseDC(HWND(m_hWnd), hDC);             // Release DC handle

  // Create our D3D class
  cglD3D::CreateParams params;
  params.hWnd    = m_hWnd;
  params.nBPP    = (nBPP == 32) ? cglD3D::BPP_32 : cglD3D::BPP_16;
  params.nWidth  = nW;
  params.nHeight = nH;
  m_pD3D = new cglD3D(params);
  // Check creation result
  if (m_pD3D == NULL || m_pD3D->isFailed())
    return;

  // Init random generator
  srand(0);
}
Пример #9
0
//---------------------------------------------------------------------
LRESULT	Window::WindowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {

#ifdef	_DEBUG
	/*
	char	buf[20];
	sprintf(buf, "0x%x : ", hWnd);
	OutputDebugString(buf);
	*/
	PutWindowMessage(message, wParam, lParam);
#endif

	if ( message==WM_CREATE )
	{
		LPCREATESTRUCT	pc = (LPCREATESTRUCT)lParam;
		Window*	pw = (Window*)(pc->lpCreateParams);
		pw->mWnd = hWnd;
		::SetWindowLong(hWnd, 0, (long)pw);
		bool b = pw->OnCreate(pc);

		gTaskbarCreatedMessage = ::RegisterWindowMessage(TEXT("TaskbarCreated"));

		return	b ? 0 : -1;
	}

	// マウスホイール対応
	if ( message == msgMOUSEWHEEL ) {
		message = WM_MOUSEWHEEL;
		DbgStr("MouseWheel fwKeys:%04x, zDelta:%d, xPos:%d, yPos:%d",
			LOWORD(wParam), (short)HIWORD(wParam),
			(short)LOWORD(lParam), (short)HIWORD(lParam) );
	}

	Window*	p=(Window*)(::GetWindowLong(hWnd, 0));
	if ( p == NULL )
		return	::DefWindowProc(hWnd, message, wParam, lParam);

	if ( message >= WM_USER && message <= 0x7FFF )
		return	p->OnUser(message, wParam, lParam);
	if ( message == gTaskbarCreatedMessage )
		return  p->OnTaskbarRestart();

	switch ( message ) {

	case WM_PAINT:
		{
			PAINTSTRUCT	thePS;
			HDC			theDC = ::BeginPaint(hWnd, &thePS);
			if (theDC != NULL) {
				p->OnPaint(theDC);
				::EndPaint(hWnd, &thePS);
			}
		}
		return	0;

	case WM_NCHITTEST:
		return	p->OnNCHitTest(MAKEPOINT(lParam));

	Handle(WM_ACTIVATE, OnActivate(LOWORD(wParam), HIWORD(wParam), (HWND)lParam));
	Handle(WM_ACTIVATEAPP, OnActivateApp(BOOL(wParam), (DWORD)lParam));
	Handle(WM_DISPLAYCHANGE, OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam));
	/*case WM_DISPLAYCHANGE:
		p->OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam);
		break;*/


	Handle(WM_COMMAND, OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND)lParam));
	Handle(WM_INITMENU, OnInitMenu(HMENU(wParam)));
	Handle(WM_CLOSE, OnClose());
	Handle(WM_DESTROY, OnDestroy());

	Handle(MM_MCINOTIFY, OnMCINotify(WORD(wParam), LONG(lParam)));

	Handle(WM_LBUTTONDOWN, OnLButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONDOWN, OnMButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONDOWN, OnRButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_LBUTTONUP, OnLButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONUP, OnMButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONUP, OnRButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_LBUTTONDBLCLK, OnLButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONDBLCLK, OnMButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONDBLCLK, OnRButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_MOUSEMOVE, OnMouseMove(MAKEPOINT(lParam), wParam));
	Handle(WM_MOUSEWHEEL, OnMouseWheel(LOWORD(wParam), (short)HIWORD(wParam), (short)LOWORD(lParam), (short)HIWORD(lParam)));
	Handle(WM_NCLBUTTONDBLCLK, OnNCLButtonDoubleClick(wParam, MAKEPOINT(lParam)));

	Handle(WM_KEYDOWN, OnKeyDown((int)wParam, (long)lParam));
	Handle(WM_KEYUP, OnKeyUp((int)wParam, (long)lParam));
	Handle(WM_DROPFILES, OnDropFiles(HDROP(wParam)));
	
	Handle(WM_TIMER, OnTimer(wParam, (TIMERPROC*)lParam));

	Handle(WM_DRAWCLIPBOARD, OnDrawClipboard());
	Handle(WM_CHANGECBCHAIN, OnChangeCBChain((HWND)wParam, (HWND)lParam));

	default:
		break;
	}
	return	::DefWindowProc(hWnd, message, wParam, lParam);
}
Пример #10
0
HRESULT fsFileStream::SetPointer(LONGLONG llPos)
{
	m_uCurPos = llPos;
	SetFilePointer (m_hFile, LONG (llPos), NULL, FILE_BEGIN);
	return S_OK;
}
Пример #11
0
//
// W_AddFile
// All files are optional, but at least one file must be
//  found (PWAD, if all required lumps are present).
// Files with a .wad extension are wadlink files
//  with multiple lumps.
// Other files are single lumps with the base filename
//  for the lump name.
//
// Reload hack removed by Lee Killough
// CPhipps - source is an enum
//
// proff - changed using pointer to wadfile_info_t
static void W_AddFile(wadfile_info_t *wadfile) 
// killough 1/31/98: static, const
{
  wadinfo_t   header;
  lumpinfo_t* lump_p;
  unsigned    i;
  int         length;
  int         startlump;
  filelump_t  *fileinfo, *fileinfo2free=NULL; //killough
  filelump_t  singleinfo;

  // open the file and add to directory
  wadfile->handle = fopen(wadfile->name, "rb");

/*
#ifdef HAVE_NET
  if (wadfile->handle == -1 && D_NetGetWad(wadfile->name)) // CPhipps
    wadfile->handle = open(wadfile->name,O_RDONLY | O_BINARY);
#endif
*/
    
  if (wadfile->handle == NULL) 
    {
      if (  strlen(wadfile->name)<=4 ||      // add error check -- killough
	         (strcasecmp(wadfile->name+strlen(wadfile->name)-4 , ".lmp" ) &&
	          strcasecmp(wadfile->name+strlen(wadfile->name)-4 , ".gwa" ) )
         )
	I_Error("W_AddFile: couldn't open %s",wadfile->name);
      return;
    }

  //jff 8/3/98 use logical output routine
  lprintf (LO_INFO," adding %s\n",wadfile->name);
  startlump = numlumps;

  if (  strlen(wadfile->name)<=4 || 
	      (
          strcasecmp(wadfile->name+strlen(wadfile->name)-4,".wad") && 
	        strcasecmp(wadfile->name+strlen(wadfile->name)-4,".gwa")
        )
     )
    {
      // single lump file
      fileinfo = &singleinfo;
      singleinfo.filepos = 0;
      singleinfo.size = LONG(I_Filelength(wadfile->handle));
      ExtractFileBase(wadfile->name, singleinfo.name);
      numlumps++;
    }
  else
    {
      // WAD file
      I_Read(wadfile->handle, &header, sizeof(header));

      if (strncmp(header.identification,"IWAD",4) &&
          strncmp(header.identification,"PWAD",4)) {
    
    	char ident[5];
    	strncpy(ident,header.identification,4);
    	iprintf("header was %s\n",ident);       	
        I_Error("W_AddFile: Wad file %s doesn't have IWAD or PWAD id", wadfile->name);
	}
      header.numlumps = LONG(header.numlumps);
      header.infotableofs = LONG(header.infotableofs);
      length = header.numlumps*sizeof(filelump_t);
      fileinfo2free = fileinfo = malloc(length);    // killough
      fseek(wadfile->handle, header.infotableofs, SEEK_SET);
      I_Read(wadfile->handle, fileinfo, length);
      numlumps += header.numlumps;
    }

    // Fill in lumpinfo
    lumpinfo = realloc(lumpinfo, numlumps*sizeof(lumpinfo_t));

    lump_p = &lumpinfo[startlump];

    for (i=startlump ; (int)i<numlumps ; i++,lump_p++, fileinfo++)
    {
        lump_p->wadfile = wadfile;                    //  killough 4/25/98
        lump_p->position = LONG(fileinfo->filepos);
        lump_p->size = LONG(fileinfo->size);
        lump_p->li_namespace = ns_global;              // killough 4/17/98
        strncpy (lump_p->name, fileinfo->name, 8);
		lump_p->source = wadfile->src;                    // Ty 08/29/98
    }

    free(fileinfo2free);      // killough
}
Пример #12
0
/// Upsampler::Upsample
void Upsampler::Upsample(UBYTE **&data,class ImageLayout *src)
{
  UWORD i;
  // Delete the old image components. Does not release the
  // memory we hold.
  delete[] m_pComponent;
  m_pComponent  = NULL;
  ReleaseComponents(data);
  //
  if (m_bChromaOnly) {
    m_ulWidth     = src->WidthOf();
    m_ulHeight    = src->HeightOf();
  } else { 
    m_ulWidth     = src->WidthOf()  * m_ucScaleX;
    m_ulHeight    = src->HeightOf() * m_ucScaleY;
  }
  //
  m_usDepth     = src->DepthOf();
  m_pComponent  = new struct ComponentLayout[m_usDepth];
  //
  // Initialize component dimensions.
  for(i = 0; i < m_usDepth; i++) {
    if (m_bChromaOnly == false || i > 0) { 
      m_pComponent[i].m_ulWidth  = src->WidthOf(i)  * m_ucScaleX;
      m_pComponent[i].m_ulHeight = src->HeightOf(i) * m_ucScaleY;
    } else {
      m_pComponent[i].m_ulWidth  = src->WidthOf(i);
      m_pComponent[i].m_ulHeight = src->HeightOf(i);
    }
    m_pComponent[i].m_ucBits   = src->BitsOf(i);
    m_pComponent[i].m_bSigned  = src->isSigned(i);
    m_pComponent[i].m_bFloat   = src->isFloat(i);
    if (m_bChromaOnly && i > 0) { 
      m_pComponent[i].m_ucSubX   = 1;
      m_pComponent[i].m_ucSubY   = 1;
    } else {
      m_pComponent[i].m_ucSubX   = src->SubXOf(i);
      m_pComponent[i].m_ucSubY   = src->SubYOf(i);
    }
  }
  //
  data = new UBYTE *[m_usDepth];
  memset(data,0,sizeof(UBYTE *) * m_usDepth);
  //
  for(i = 0;i < m_usDepth;i++) {
    UBYTE bps = (m_pComponent[i].m_ucBits + 7) >> 3;
    if (m_pComponent[i].m_bFloat && m_pComponent[i].m_ucBits == 16)
      bps = sizeof(FLOAT); // stored as float
    //
    data[i]                           = new UBYTE[m_pComponent[i].m_ulWidth * m_pComponent[i].m_ulHeight * bps];
    m_pComponent[i].m_ulBytesPerPixel = bps;
    m_pComponent[i].m_ulBytesPerRow   = bps * m_pComponent[i].m_ulWidth;
    m_pComponent[i].m_pPtr            = data[i];
  }
  //
  for(i = 0;i < m_usDepth;i++) {
    UBYTE sx,sy;
    //
    if (m_bChromaOnly == false || i > 0) { 
      sx = m_ucScaleX;
      sy = m_ucScaleY;
    } else {
      sx = 1;
      sy = 1;
    }
    //
    if (isSigned(i)) {
      if (BitsOf(i) <= 8) {
	BilinearFilter<BYTE>((BYTE *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			(BYTE *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			WidthOf(i),HeightOf(i),
			BYTE(-1UL << (BitsOf(i) - 1)),BYTE((1UL << (BitsOf(i) - 1)) - 1),
			sx,sy);
      } else if (!isFloat(i) && BitsOf(i) <= 16) {
	BilinearFilter<WORD>((WORD *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			(WORD *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			WidthOf(i),HeightOf(i),
			WORD(-1UL << (BitsOf(i) - 1)),WORD((1UL << (BitsOf(i) - 1)) - 1),
			sx,sy);
      } else if (!isFloat(i) && BitsOf(i) <= 32) {
	BilinearFilter<LONG>((LONG *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			(LONG *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			WidthOf(i),HeightOf(i),
			LONG(-1UL << (BitsOf(i) - 1)),LONG((1UL << (BitsOf(i) - 1)) - 1),
			sx,sy);
      } else if (isFloat(i) && BitsOf(i) <= 32) {
	BilinearFilter<FLOAT>((FLOAT *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			(FLOAT *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			 WidthOf(i),HeightOf(i),
			 -HUGE_VAL,HUGE_VAL,
			 sx,sy);
      } else if (isFloat(i) && BitsOf(i) == 64) {
	BilinearFilter<DOUBLE>((DOUBLE *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			  (DOUBLE *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			  WidthOf(i),HeightOf(i),
			  -HUGE_VAL,HUGE_VAL,
			  sx,sy);
      } else {
	throw "unsupported data type";
      }
    } else {
      if (BitsOf(i) <= 8) {
	BilinearFilter<UBYTE>((UBYTE *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			(UBYTE *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			 WidthOf(i),HeightOf(i),
			 0,UBYTE((1UL << BitsOf(i)) - 1),
			 sx,sy);
      } else if (!isFloat(i) && BitsOf(i) <= 16) {
	BilinearFilter<UWORD>((UWORD *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			 (UWORD *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			 WidthOf(i),HeightOf(i),
			 0,UWORD((1UL << BitsOf(i)) - 1),
			 sx,sy);
      } else if (!isFloat(i) && BitsOf(i) <= 32) {
	BilinearFilter<ULONG>((ULONG *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			 (ULONG *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			 WidthOf(i),HeightOf(i),
			 0,LONG((1UL << BitsOf(i)) - 1),
			 sx,sy);
      } else if (isFloat(i) && BitsOf(i) <= 32) {
	BilinearFilter<FLOAT>((FLOAT *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			(FLOAT *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			 WidthOf(i),HeightOf(i),
			 0.0,HUGE_VAL,
			 sx,sy);
      } else if (isFloat(i) && BitsOf(i) == 64) {
	BilinearFilter<DOUBLE>((DOUBLE *)src->DataOf(i),src->BytesPerPixel(i),src->BytesPerRow(i),
			  (DOUBLE *)DataOf(i),BytesPerPixel(i),BytesPerRow(i),
			  WidthOf(i),HeightOf(i),
			  0.0,HUGE_VAL,
			  sx,sy);
      } else {
	throw "unsupported data type";
      }
    }
  }
  //
  Swap(*src);
}
Пример #13
0
/*
==================
=
= R_InitTextures
=
= Initializes the texture list with the textures from the world map
=
==================
*/

void R_InitTextures (void)
{
	maptexture_t	*mtexture;
	texture_t		*texture;
	mappatch_t	*mpatch;
	texpatch_t	*patch;
	int			i,j;
	int			*maptex, *maptex2, *maptex1;
	char		name[9], *names, *name_p;
	int			*patchlookup;
	int			totalwidth;
	int			nummappatches;
	int			offset, maxoff, maxoff2;
	int			numtextures1, numtextures2;
	int			*directory;

//
// load the patch names from pnames.lmp
//
	name[8] = 0;
	names = W_CacheLumpName ("PNAMES", PU_STATIC);
	nummappatches = LONG ( *((int *)names) );
	name_p = names+4;
	//rww begin
	patchlookup = alloca (nummappatches*sizeof(*patchlookup));
	//patchlookup = Z_Malloc(nummappatches*sizeof(*patchlookup), PU_STATIC, 0);
	//rww end
	for (i=0 ; i<nummappatches ; i++)
	{
		strncpy (name,name_p+i*8, 8);
		patchlookup[i] = W_CheckNumForName (name);
	}
	Z_Free (names);

//
// load the map texture definitions from textures.lmp
//
	maptex = maptex1 = W_CacheLumpName ("TEXTURE1", PU_STATIC);
	numtextures1 = LONG(*maptex);
	maxoff = W_LumpLength (W_GetNumForName ("TEXTURE1"));
	directory = maptex+1;

	if (W_CheckNumForName ("TEXTURE2") != -1)
	{
		maptex2 = W_CacheLumpName ("TEXTURE2", PU_STATIC);
		numtextures2 = LONG(*maptex2);
		maxoff2 = W_LumpLength (W_GetNumForName ("TEXTURE2"));
	}
	else
	{
		maptex2 = NULL;
		numtextures2 = 0;
		maxoff2 = 0;
	}
	numtextures = numtextures1 + numtextures2;

	//rww begin
	ST_Message("R_InitTextures: %i\n", numtextures);
	//rww end

	textures = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecomposite = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0);
	textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0);

	totalwidth = 0;

	for (i=0 ; i<numtextures ; i++, directory++)
	{
		if (i == numtextures1)
		{	// start looking in second texture file
			maptex = maptex2;
			maxoff = maxoff2;
			directory = maptex+1;
		}

		offset = LONG(*directory);
		if (offset > maxoff)
			I_Error ("R_InitTextures: bad texture directory");
		mtexture = (maptexture_t *) ( (byte *)maptex + offset);

#ifdef _TEXTURE_PATCH_DEBUG
		ST_Message("%s: %i, %i, %i, %i, %i     \n", mtexture->name,
			mtexture->patches[0].patch, mtexture->patches[0].colormap,
			mtexture->patches[0].originx, mtexture->patches[0].originy,
			mtexture->patches[0].stepdir);
	#ifdef _HEXENDS
		{
			int j = 0;
			while (j < 60) {
				swiWaitForVBlank();
				j++;
			}
		}
	#endif
#endif

		texture = textures[i] = Z_Malloc (sizeof(texture_t) 
			+ sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1), PU_STATIC,
			0);
		texture->width = SHORT(mtexture->width);
		texture->height = SHORT(mtexture->height);
		texture->patchcount = SHORT(mtexture->patchcount);
		memcpy (texture->name, mtexture->name, sizeof(texture->name));
		mpatch = &mtexture->patches[0];
		patch = &texture->patches[0];
//		ST_Message("tex (%s: %i %i %i %i %i %i)\n", texture->name, texture->width, texture->height,
//			texture->patchcount, mtexture->patchcount, mtexture->patches[0].patch, patchlookup[SHORT(mpatch->patch)]);

		for (j=0 ; j<texture->patchcount ; j++, mpatch++, patch++)
		{
			patch->originx = SHORT(mpatch->originx);
			patch->originy = SHORT(mpatch->originy);
			patch->patch = patchlookup[SHORT(mpatch->patch)];
			if (patch->patch == -1)
				I_Error (
				"R_InitTextures: Missing patch in texture %s",texture->name);
		}		

//		ST_Message("tex (%s: %i %i %i %i %i %i)\n", texture->name, texture->width, texture->height,
//			texture->patchcount, texture->patches[0].originx, texture->patches[0].originy, texture->patches[0].patch);

		texturecolumnlump[i] = Z_Malloc (texture->width*2, PU_STATIC,0);
		texturecolumnofs[i] = Z_Malloc (texture->width*2, PU_STATIC,0);
		j = 1;
		while (j*2 <= texture->width)
			j<<=1;
		texturewidthmask[i] = j-1;
		textureheight[i] = texture->height<<FRACBITS;
		
		totalwidth += texture->width;
	}

	Z_Free (maptex1);
	if (maptex2)
		Z_Free (maptex2);

//
// precalculate whatever possible
//		
	for (i=0 ; i<numtextures ; i++)
	{
		R_GenerateLookup (i);
		if(!(i&31)) ST_Progress();
	}

//
// translation table for global animation
//
	texturetranslation = Z_Malloc ((numtextures+1)*4, PU_STATIC, 0);
	for (i=0 ; i<numtextures ; i++)
		texturetranslation[i] = i;

	//rww begin
	//Z_Free(patchlookup);
	//rww end
Пример #14
0
/*
===================
=
= R_GenerateLookup
=
===================
*/

void R_GenerateLookup (int texnum)
{
	texture_t	*texture;
	byte		*patchcount;		// [texture->width]
	texpatch_t	*patch;	
	patch_t		*realpatch;
	int			x, x1, x2;
	int			i;
	short		*collump;
	unsigned short	*colofs;
	
	texture = textures[texnum];

	//ST_Message("lookup (%s: %i %i %i %i %i %i)\n", texture->name, texture->width, texture->height,
	//	texture->patchcount, texture->patches[0].originx, texture->patches[0].originy, texture->patches[0].patch);

	texturecomposite[texnum] = 0;	// composited not created yet
	texturecompositesize[texnum] = 0;
	collump = texturecolumnlump[texnum];
	colofs = texturecolumnofs[texnum];
	
//
// count the number of columns that are covered by more than one patch
// fill in the lump / offset, so columns with only a single patch are
// all done
//
	//rww begin
	patchcount = (byte *)alloca (texture->width);
	//patchcount = (byte *)Z_Malloc(texture->width, PU_STATIC, 0);
	//rww end
	memset (patchcount, 0, texture->width);
	patch = texture->patches;

	for (i=0 , patch = texture->patches; i<texture->patchcount ; i++, patch++)
	{
		realpatch = W_CacheLumpNumTexture (texture, patch->patch, PU_CACHE, -1);
		x1 = patch->originx;
		x2 = x1 + SHORT(realpatch->width);
		if (x1 < 0)
			x = 0;
		else
			x = x1;
		if (x2 > texture->width)
			x2 = texture->width;
		for ( ; x<x2 ; x++)
		{
			patchcount[x]++;
			collump[x] = patch->patch;
			colofs[x] = LONG(realpatch->columnofs[x-x1])+3;
		}
	}
	
	for (x=0 ; x<texture->width ; x++)
	{
		if (!patchcount[x])
		{
			//rww begin
			ST_Message ("R_GenerateLookup: column without a patch (%s)\n", texture->name);
			//I_Error("col without patch (%s (%i): %i %i %i %i %i %i)\n", texture->name, texnum, texture->width, texture->height,
			//	texture->patchcount, texture->patches[0].originx, texture->patches[0].originy, texture->patches[0].patch);
			//rww end
			return;
		}
//			I_Error ("R_GenerateLookup: column without a patch");
		if (patchcount[x] > 1)
		{
			collump[x] = -1;	// use the cached block
			colofs[x] = texturecompositesize[texnum];
			if (texturecompositesize[texnum] > 0x10000-texture->height)
				I_Error ("R_GenerateLookup: texture %i is >64k",texnum);
			texturecompositesize[texnum] += texture->height;
		}
	}	

	//rww begin
	//Z_Free(patchcount);
	//rww end