コード例 #1
0
ファイル: PisteDraw.cpp プロジェクト: piotrulos/PK2remakes
int PisteDraw_Paletti_Pyorita(UCHAR eka_vari, UCHAR vika_vari)
{
	UCHAR i;
	
	if (FAILED(PD_lpddpal->GetEntries(0,0,255,PD_paletti_nyt))) {
		PisteLog_Kirjoita("[Error] Piste Draw: Palette get entries failed!\n");		
		return PD_VIRHE;
	}

	PALETTEENTRY temp_vari;
		
	temp_vari.peRed   = PD_paletti_nyt[vika_vari].peRed;
	temp_vari.peGreen = PD_paletti_nyt[vika_vari].peGreen;
	temp_vari.peBlue  = PD_paletti_nyt[vika_vari].peBlue;

	for (i=vika_vari;i>eka_vari;i--)
	{
		PD_paletti_nyt[i].peRed   = PD_paletti_nyt[i-1].peRed;
		PD_paletti_nyt[i].peGreen = PD_paletti_nyt[i-1].peGreen;
		PD_paletti_nyt[i].peBlue  = PD_paletti_nyt[i-1].peBlue;
	}

	PD_paletti_nyt[eka_vari].peRed   = temp_vari.peRed;
	PD_paletti_nyt[eka_vari].peGreen = temp_vari.peGreen;
	PD_paletti_nyt[eka_vari].peBlue  = temp_vari.peBlue;

	if (FAILED(PD_lpddpal->SetEntries(0,0,255,PD_paletti_nyt))) {
		PisteLog_Kirjoita("[Error] Piste Draw: Palette set entries failed!\n");	
		return PD_VIRHE;	
	}
	
	return 0;
}
コード例 #2
0
ファイル: PisteDraw.cpp プロジェクト: piotrulos/PK2remakes
int PisteDraw_Paletti_Set(void)
{
	if (FAILED(PD_lpddpal->SetEntries(0,0,255,PD_paletti_nyt))) {
		PisteLog_Kirjoita("[Error] Piste Draw: Palette set failed!\n");
		return PD_VIRHE;	
	}

	return 0;
}
コード例 #3
0
ファイル: DDrawCapture.cpp プロジェクト: CasperGemini/OBS
    void ReloadPrimarySurfacePaletteEntries()
    {
        if (!primary_surface_palette_ref)
            return;

        HRESULT err;
        ddrawPaletteSetEntries.Unhook();
        if (FAILED(err = primary_surface_palette_ref->SetEntries(0, 0, numEntries, entries)))
        {
            logOutput << CurrentTimeString() << "ReloadPrimarySurfacePaletteEntries(): could not set entires" << endl;
            printDDrawError(err);
        }
        ddrawPaletteSetEntries.Rehook();
    }
コード例 #4
0
ファイル: version5.cpp プロジェクト: cwilko/voxelMap
int Set_Palette_Entry(int index, int red, int blue, int green)
{
	PALETTEENTRY colour;

	colour.peRed = (BYTE)red;
	colour.peGreen = (BYTE)green;
	colour.peBlue = (BYTE)blue;
	colour.peFlags = PC_NOCOLLAPSE;

	lpddpal->SetEntries(0,index,1,&colour);

	memcpy(&colour_palette[index], &colour, sizeof(PALETTEENTRY));

	return 1;
}
コード例 #5
0
ファイル: video_win32_ddraw.cpp プロジェクト: eswartz/emul
static void screen_updatepalette(void)
{
	HRESULT ret;
	int idx;
	if (!lpDDPal)
		return;
	//log("screen_updatepalette\n");
	
//	for (idx = 1; idx < 17; idx ++)
//		DD_RGBTOPAL(idx, win_rgbmap[idx]);
/*	ret = lpDDPal->SetEntries(0, 0, 17, pals+rand()%16);
	if (ret != DD_OK)
		error(_("videoupdatepalette:  SetPalette failed (%d)\n"), ret);*/
	for (idx = 0; idx < 17; idx ++)
		DD_RGBTOPAL(idx, win_rgbmap[idx]);
	ret = lpDDPal->SetEntries(0, 0, 17, pals);
	if (ret != DD_OK)
		module_logger(&win32DirectDrawVideo, _L|LOG_ERROR|LOG_USER, _("videoupdatepalette:  SetPalette failed (%d)\n"), ret);
}
コード例 #6
0
ファイル: DDrawCapture.cpp プロジェクト: CasperGemini/OBS
HRESULT STDMETHODCALLTYPE PaletteSetEntries(LPDIRECTDRAWPALETTE palette, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
{
    //logOutput << CurrentTimeString() << "Hooked SetEntries()" << endl;

    ddrawPaletteSetEntries.Unhook();
    HRESULT hr = palette->SetEntries(dwFlags, dwStartingEntry, dwCount, lpEntries);
    ddrawPaletteSetEntries.Rehook();

    // update buffer palette
    if (SUCCEEDED(hr))
    {
        if (g_CurrentPalette.bInitialized)
        {
            memcpy(g_CurrentPalette.entries + dwStartingEntry, lpEntries, 4 * dwCount); // each entry is 4 bytes if DDCAPS_8BITENTRIES flag is not set
        }
    }

    return hr;
}
コード例 #7
0
ファイル: PisteDraw.cpp プロジェクト: piotrulos/PK2remakes
int PisteDraw_Fade_Paletti_Do(int pros)
{
	UCHAR i;
	
	if (FAILED(PD_lpddpal->GetEntries(0,0,255,PD_paletti_nyt))) {
		PisteLog_Kirjoita("[Error] Piste Draw: Palette get entries failed!\n");
		return PD_VIRHE;
	}

	for (i=0;i<255;i++)
	{
		PD_paletti_nyt[i].peRed   = (PD_paletti[i].peRed   * pros / 100);
		PD_paletti_nyt[i].peGreen = (PD_paletti[i].peGreen * pros / 100);
		PD_paletti_nyt[i].peBlue  = (PD_paletti[i].peBlue  * pros / 100);
	}

	if (FAILED(PD_lpddpal->SetEntries(0,0,255,PD_paletti_nyt))) {
		PisteLog_Kirjoita("[Error] Piste Draw: Palette set entries failed!\n");
		return PD_VIRHE;
	}
	
	return 0;
}
コード例 #8
0
ファイル: video_win32_ddraw.cpp プロジェクト: eswartz/emul
static void	win_SetFullScreenMode(void)
{
	HRESULT	ret;

//	log("win_SetFullScreenMode\n");
	if (lpDD)
	{
		/* get exclusive mode (for fullscreen and memory locking access) */
		ret = lpDD->SetCooperativeLevel(hWndScreen,
				DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT |
				DDSCL_ALLOWMODEX);
		if (ret != DD_OK)
			DDFAIL(_("SetCooperativeLevel failed (%d)\n"), ret);
		
		/*  Set our video mode */
		ret = lpDD->SetDisplayMode(fsx, fsy, 8, 0, DDSDM_STANDARDVGAMODE);
		if (ret != DD_OK)
			DDFAIL(_("SetDisplayMode\n"), ret);
		
		/*  Use our palette */
		if (lpDDPal)
		{
			ret = lpDDPal->SetEntries(0 /*flags */, 0, 256, pals);
			if (ret != DD_OK)
				DDFAIL(_("SetEntries failed (%d)\n"), ret);
		}
		
		#warning fix this later
		// adjust rect for text mode!
		screenrect.left = 0;
		screenrect.top = 0;
		screenrect.right = 256;
		screenrect.bottom = 192;

	}
}
コード例 #9
0
int Game_Init(void *parms = NULL, int num_parms = 0)
{
// this is called once after the initial window is created and
// before the main event loop is entered, do all your initialization
// here

// create IDirectDraw interface 7.0 object and test for error
if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)))
   return(0);

// set cooperation to full screen
if (FAILED(lpdd->SetCooperativeLevel(main_window_handle, 
                                      DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | 
                                      DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
   return(0);

// set display mode to 640x480x8
if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0)))
   return(0);

// we need a complex surface system with a primary and backbuffer

// clear ddsd and set size
DDRAW_INIT_STRUCT(ddsd); 

// enable valid fields
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

// set the backbuffer count field to 1, use 2 for triple buffering
ddsd.dwBackBufferCount = 1;

// request a complex, flippable
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;

// create the primary surface
if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL)))
   return(0);

// now query for attached surface from the primary surface

// this line is needed by the call
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;

// get the attached back buffer surface
if (FAILED(lpddsprimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsback)))
  return(0);

// build up the palette data array
for (int color=1; color < 255; color++)
    {
    // fill with random RGB values
    palette[color].peRed   = rand()%256;
    palette[color].peGreen = rand()%256;
    palette[color].peBlue  = rand()%256;

    // set flags field to PC_NOCOLLAPSE
    palette[color].peFlags = PC_NOCOLLAPSE;
    } // end for color

// now fill in entry 0 and 255 with black and white
palette[0].peRed     = 0;
palette[0].peGreen   = 0;
palette[0].peBlue    = 0;
palette[0].peFlags   = PC_NOCOLLAPSE;

palette[255].peRed   = 255;
palette[255].peGreen = 255;
palette[255].peBlue  = 255;
palette[255].peFlags = PC_NOCOLLAPSE;

// create the palette object
if (FAILED(lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | 
                                DDPCAPS_INITIALIZE, 
                                palette,&lpddpal, NULL)))
return(0);

// finally attach the palette to the primary surface
if (FAILED(lpddsprimary->SetPalette(lpddpal)))
   return(0);

// set clipper up on back buffer since that's where well clip
RECT screen_rect= {0,0,SCREEN_WIDTH-1,SCREEN_HEIGHT-1};
lpddclipper = DDraw_Attach_Clipper(lpddsback,1,&screen_rect);

// load the 8-bit image
if (!Load_Bitmap_File(&bitmap,"alley8.bmp"))
   return(0);

// load it's palette into directdraw
if (FAILED(lpddpal->SetEntries(0,0,MAX_COLORS_PALETTE,bitmap.palette)))
   return(0);

// clean the surfaces
DDraw_Fill_Surface(lpddsprimary,0);
DDraw_Fill_Surface(lpddsback,0);

// create the buffer to hold the background
lpddsbackground = DDraw_Create_Surface(640,480,0,-1);

// copy the background bitmap image to the background surface 

// lock the surface
lpddsbackground->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);

// get video pointer to primary surfce
UCHAR *image_buffer = (UCHAR *)ddsd.lpSurface;       

// test if memory is linear
if (ddsd.lPitch == SCREEN_WIDTH)
   {
   // copy memory from double buffer to primary buffer
   memcpy((void *)image_buffer, (void *)bitmap.buffer, SCREEN_WIDTH*SCREEN_HEIGHT);
   } // end if
else
   { // non-linear

   // make copy of source and destination addresses
   UCHAR *dest_ptr = image_buffer;
   UCHAR *src_ptr  = bitmap.buffer;

   // memory is non-linear, copy line by line
   for (int y=0; y < SCREEN_HEIGHT; y++)
       {
       // copy line
       memcpy((void *)dest_ptr, (void *)src_ptr, SCREEN_WIDTH);

       // advance pointers to next line
       dest_ptr+=ddsd.lPitch;
       src_ptr +=SCREEN_WIDTH;
       } // end for

   } // end else

// now unlock the primary surface
if (FAILED(lpddsbackground->Unlock(NULL)))
   return(0);

// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);

// seed random number generator
srand(GetTickCount());

// initialize all the aliens (in real life do this in a loop or function)

// alien on level 1 of complex

aliens[0].x              = rand()%SCREEN_WIDTH;
aliens[0].y              = 116 - 72;                  
aliens[0].velocity       = 2+rand()%4;
aliens[0].current_frame  = 0;             
aliens[0].counter        = 0;       
aliens[0].width          = 72; // set real size
aliens[0].height         = 80;
aliens[0].scale          = ((float)(1+rand()%20))/10; // scale from 0.1 to 2.0
// fix up feet so they still contact floor
aliens[0].y+=(72 - aliens[0].scale*72);

// alien on level 2 of complex

aliens[1].x              = rand()%SCREEN_WIDTH;
aliens[1].y              = 246 - 72;                  
aliens[1].velocity       = 2+rand()%4;
aliens[1].current_frame  = 0;             
aliens[1].counter        = 0;  
aliens[1].width          = 72; // set real size
aliens[1].height         = 80;
aliens[1].scale          = ((float)(1+rand()%20))/10; // scale from 0.1 to 2.0
// fix up feet so they still contact floor
aliens[1].y+=(72 - aliens[1].scale*72);



// alien on level 3 of complex

aliens[2].x              = rand()%SCREEN_WIDTH;
aliens[2].y              = 382 - 72;                  
aliens[2].velocity       = 2+rand()%4;
aliens[2].current_frame  = 0;             
aliens[2].counter        = 0;  
aliens[2].width          = 72; // set real size
aliens[2].height         = 80;
aliens[2].scale          = ((float)(1+rand()%20))/10; // scale from 0.1 to 2.0

// fix up feet so they still contact floor
aliens[2].y+=(72 - aliens[2].scale*72);


// now load the bitmap containing the alien imagery
// then scan the images out into the surfaces of alien[0]
// and copy then into the other two, be careful of reference counts!

// load the 8-bit image
if (!Load_Bitmap_File(&bitmap,"dedsp0.bmp"))
   return(0);

// create each surface and load bits
for (int index = 0; index < 3; index++)
    {
    // create surface to hold image
    aliens[0].frames[index] = DDraw_Create_Surface(72,80,0);

    // now load bits...
    Scan_Image_Bitmap(&bitmap,                 // bitmap file to scan image data from
                      aliens[0].frames[index], // surface to hold data
                      index, 0);               // cell to scan image from    

    } // end for index

// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);

// now for the tricky part. There is no need to create more surfaces with the same
// data, so I'm going to copy the surface pointers member for member to each alien
// however, be careful, since the reference counts do NOT go up, you still only need
// to release() each surface once!

for (index = 0; index < 3; index++)
    aliens[1].frames[index] = aliens[2].frames[index] = aliens[0].frames[index];

// return success or failure or your own return code here
return(1);

} // end Game_Init
コード例 #10
0
ファイル: PisteDraw.cpp プロジェクト: piotrulos/PK2remakes
int PisteDraw_Lataa_Kuva(int index, char *filename, bool lataa_paletti)
{
	BITMAP_FILE		bitmap;

	bool ok = false;

	char paate[4];

	for (int i=0;i<4;i++)
		paate[i] = toupper(filename[strlen(filename)-3+i]);
	paate[4] = '\0';

	if (strcmp(paate,"BMP")==0)
	{
		ok = true;
		if (PD_buffers[index].lpdds)
		{
			if (PisteDraw_Load_Bitmap(&bitmap, filename) != 0)
			{
				strcpy(virhe,"Could not load picture ");
				strcat(virhe,filename);
				strcat(virhe,"!");
				PisteLog_Kirjoita("[Error] Piste Draw: ");
				PisteLog_Kirjoita(virhe);
				PisteLog_Kirjoita("\n");
				return PD_VIRHE;
			}

			DD_INIT_STRUCT(PD_ddsd);
			
			if (FAILED(PD_buffers[index].lpdds->Lock(NULL,&PD_ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL)))
			{
				strcpy(virhe,"Could not lock surface after loading a picture!");
				PisteLog_Kirjoita("[Error] Piste Draw: Could not lock surface after loading a picture! \n");
				return PD_VIRHE;
			}

			UCHAR *back_buffer = (UCHAR *)PD_ddsd.lpSurface; 

			int x;
			int y;
			int leveys, korkeus;

			if (bitmap.bitmapinfoheader.biWidth > PD_buffers[index].leveys)
				leveys = PD_buffers[index].leveys;
			else
				leveys = bitmap.bitmapinfoheader.biWidth;

			if (bitmap.bitmapinfoheader.biHeight > PD_buffers[index].korkeus)
				korkeus = PD_buffers[index].korkeus;
			else
				korkeus = bitmap.bitmapinfoheader.biHeight;

			for (y=0; y<korkeus; y++)
			{
				for (x=0; x<leveys; x++)
				{
					back_buffer[x+y*PD_ddsd.lPitch] = bitmap.buffer[x+y*bitmap.bitmapinfoheader.biWidth];
				}
			}

			if (FAILED(PD_buffers[index].lpdds->Unlock(NULL)))
			{
				strcpy(virhe,"Could not unlock surface after loading a picture!");
				PisteLog_Kirjoita("[Error] Piste Draw: Could not unlock surface after loading a picture! \n");
				return PD_VIRHE;
			}


			PisteDraw_Unload_Bitmap_File(&bitmap);
			
			if (lataa_paletti)
			{
			
				if (FAILED(PD_lpddpal->SetEntries(0,0,PD_max_varit, bitmap.paletti)))
				{
					strcpy(virhe,"Could not set palette after loading a picture!");
					PisteLog_Kirjoita("[Error] Piste Draw: Could not set palette after loading a picture! \n");
					return PD_VIRHE;
				}

				for (int pi=0;pi<256;pi++)
				{
					PD_paletti[pi].peBlue  = bitmap.paletti[pi].peBlue;
					PD_paletti[pi].peRed   = bitmap.paletti[pi].peRed;
					PD_paletti[pi].peGreen = bitmap.paletti[pi].peGreen;
					PD_paletti[pi].peFlags = bitmap.paletti[pi].peFlags;
				}

			}

		}
		else
			return PD_VIRHE;
	}

	if (strcmp(paate,"PCX")==0)
	{
		ok = true;
		if (PisteDraw_Lataa_PCX(filename, index, lataa_paletti) == PD_VIRHE) {
			strcpy(virhe,"Could not load picture ");
			strcat(virhe,filename);
			strcat(virhe,"!");
			PisteLog_Kirjoita("[Error] Piste Draw: ");
			PisteLog_Kirjoita(virhe);
			PisteLog_Kirjoita("\n");
			return PD_VIRHE;
		}
	}

	if (!ok)
	{
		strcpy(virhe,"Could not load bitmap file of type ");
		strcat(virhe,paate);
		return PD_VIRHE;
	}

	return 0;
}