This topic is now archived and is closed to further replies.


8-bit TOTWGPG BOB engine to 16-bit?

Recommended Posts

hi all, anyone who converted the 8-bit engine from the TOTWGPG's book to handle 16-bit graphics? i'm tired and irritated as hell cause i can't get it to work, so i will post here and then go to bed. i turned andre's bob engine into a class which i call CSprite, and i wrote a bitmap loader that handles loading of bitmap data and the conversion of 24-bit to 16-bit. so far so good, cause the loader works and i'm able to copy the contents of the bitmap data to a directdrawsurface, and then blt it to screen. no problem with bitmap loader. after doing that i thought it would be cool to be able to extract bitmaps from the bitmap data and copy it into m*n dxsurfaces just like andre is doing it in the book. i copied his code into my CSprite class, and then begun to make some modifications to make it work with 16-bit pointers instead, but here is where i ran into a wall. it simply doesn't work, and i guess i'm doing something wrong with the pointers. i know for sure that cbitmap->buffer points to valid bitmap data, and that images[frame] is a valid dxsurface. anyone can see where my mistake is located? i'd better go catch some sleep now before i go insane. thanks! btw, is there some 16-bit BOB engine on the cd of TOTWGPG? if so, where?
bool CSprite::LoadFrame(CBitmap *cbitmap, int frame, int cx, int cy, int mode)
	// this function extracts a bitmap out of a bitmap file

	// when i init the csprite object i create all needed dxsurfaces to

	// specified width and height. i store width and height of surface in

	// class member varaibles width and heigh (used in this function for

	// advancing of pointers.

	// working pointers

	WORD *source_ptr = NULL; 
	WORD *dest_ptr = NULL;

	// test the mode of extraction, cell based or absolute

		// re-compute x, y

		cx = cx*(width+1)+1;
		cy = cy*(height+1)+1;

	// extract bitmap data

	source_ptr = cbitmap->buffer + cy*cbitmap->bmInfoHeader.biWidth + cx;
	// get addr to the destination surface

	memset(&ddsd, 0, sizeof DDSURFACEDESC2);
	ddsd.dwSize = sizeof DDSURFACEDESC2;

	// images frame is a dxsurface

	// assign a pointer to the memory surface for manipulation

	dest_ptr = (WORD *)ddsd.lpSurface;
	int bytesPerLine = cbitmap->bmInfoHeader.biWidth * 2;

	// iterate through each scanline and copy bitmap

	for (int index_y = 0; index_y < height; index_y++)
		// copy next tine of data to destination

		memcpy(dest_ptr, source_ptr, bytesPerLine);
		// advance pointers

		dest_ptr += ddsd.lPitch / 2;
		source_ptr += cbitmap->bmInfoHeader.biWidth;

	// return success

	return true;
[edited by - en3my on August 15, 2002 7:12:07 AM]

Share this post

Link to post
Share on other sites
yeah en3my, i have converted the code into dealing 16-bit. furthermore, i believe that the 16-bit engine can be found in the goodies folder on the cd that is bundled with TOTWGPG. after looking through your code it seems like you forgot to flip the bitmap you loaded into memory from file, and that's why everything seems to be all fucked up when trying to do something with the data. even you didn't dump your loading code, i know it's the case cause i'm one hell of a coder. more sleep for you wouldn't hurt either, cause if you keep on like this it could lead to shizofrenia resulting in you answering your own questions and the like. :D

[edited by - en3my on August 15, 2002 8:05:44 AM]

Share this post

Link to post
Share on other sites