Are you tired of asking why your program crashes when you use WM_PAINT? Are you tired of tracing memory leaks, restudying BitBlt and MEMDC code when you don't have to? Tired of setting up a back buffer for flicker-free drawings?

Attached is the beginning of my WankerLib GDI library, I intend it to be easy to use - via a static .OBJ to link with, no .DLL's to use or anything complicated.

You can use the arrow keys to navigate, space bar to 'scan', or escape to exit. All you can do with it right now is move from room to room and see the ultra-fantastic basic collision detection (eg. boxy).

Basic usage of library:

invoke BackBuffer,1024,768
- create a backbuffer

invoke LoadBANK,ADDR filename, bank#, 0,0, 96,96
- load bitmap (.BMP) filename into bank# (0 - 32); each tile in bitmap is 96x96

invoke SetDCBNK,bank#,scratch_memDC
- set bank# up to be blitted

invoke BitBlt/invoke TransparentBlt
- note: sprite system has yet to be implemented.

to draw to the bank, all you have to do is:
invoke SetDCBNK, 3, WND.memDC
invoke SetPixelV, WND.memDC, mx, my

then to flip:
invoke BitBlt, WND.hDC,0,0,1024,768,WND.memDC,0,0,SRCCOPY

It is flicker-free.
Posted on 2004-06-11 06:06:21 by drarem
Updates (see attached file below):

* Can load up to 32 bitmaps (which can be tiled)

* Up to 512x32 sprite frames (individual sprites, in theory)

* Better cleanup, it shouldn't crash an windoze 98 box

* Memory for sprites is all dynamic except when used for testing and debugging

Is anyone with me on this yet? There is much to do, I am happy I got this far with it.. the current demo shows three sprites as you use cursor keys to move it around on map.

here is a clip:

invoke Sprite,layer0,px,py,10
sub px,45
add px,128
sub py,63
invoke Sprite,player,px,py,2
add py,63
sub px,128

and to initialize them i do (thank you CTEXT macro writer):

invoke LoadBANK, CTEXT("player_noseethru.bmp"),player,0,0,256,128
invoke LoadBANK,CTEXT("tiles.bmp"),layer0,0,0,64,64

invoke SprInit,layer0,800,600,10,10
invoke SprInit,player,256,128,4,2

The SprInit function I need to change around a bit, right now it says layer 0 is 800x600 with 10x10 sprites, meaning they are 80x60 is resolution, and player is a bitmap of 256x128 with 4x2 sprites, resolution = 256/4,128/2 (64x64)..

The numbers for the LoadBANK function do nothing, I could either remove them or change them as tile/sprite initializers.
Posted on 2004-07-03 02:27:36 by drarem
New attachment, see below. For the demo, use cursor keys to move player, go from room0 to room1 as before, this time a row of sprites are coming from the top to the bottom continually as a test.

Moved from TransparentBlt to the create mask on the fly and bitblt. Ok so I cheated with the player, only cause he is animated at the moment.. the rest is all on the fly.

Memproof only shows one error, prob cause I am not closing an icon properly or something - so this should run steady and not crash. Yes I am using 3 DC's - will migrate to 1 eventually.

Features are (and can/will be improved):

Simple function call to create and cleanup the primary DC's ... look ma, no more dirty hands (in other words, working towards a simple library which is universal)..

Up to 32 sprite banks (or tiled bitmaps)..

then call the sprite such as:

invoke Sprite, grass, x, y, image_number (starting at 0 for frame).

Here is a coding example:

.elseif uMsg == WM_CREATE

invoke BackBuffer,hWin,800,600 ;initialize both the memDC and backDC for flipping purposes..

invoke LoadBANK,CTEXT("bck1.bmp"),bckgnd,1,1,0 ;800,600 bitmap, 1 frame (1x1)

;this still needs updating, should probably pass it actual sprite resolution
;for oddball bitmaps

invoke LoadBANK,CTEXT("tiles.bmp"),layer0,10,10,1 ;800,600 bitmap, 10x10 frames

invoke LoadBANK, CTEXT("player_noseethru3.bmp"),player,4,2,1
;256x128 bitmap of 4x2 frames


invoke Sprite,player,clax,clay,7
invoke Sprite,player,x,y,2
invoke flip ;copy backDC to hDC

finally when closing, do a simple:
invoke cleanup

It's slow at the moment, still to do list:

* dirty rectangles so the map continually redrawing doesn't slow things down
* SpriteAnim command.. pass it something like: playerJumpLeft DD 0,1,2,3,4,5,SLP ;SLP=255=loop
Posted on 2004-07-16 02:58:14 by drarem
last update for a bit, until I get situated. As usual, see attachment below.

It should run faster now, I am using the compiled sprite method, if I have the terminology correct. There are still a few bugs but for the most part it works.

Please give me feedback if you have any crashes, errors, or comments.
Posted on 2004-07-17 04:43:17 by drarem
one more try for the attachment..
Posted on 2004-07-17 04:44:29 by drarem
Hi, i've downloaded the attachment twice, and it says "unexpected end of archive" in WinRAR. I wish to see what has been done. Maybe i can help some, but i shall see the code before saying that i will. rgs.
Posted on 2004-08-28 05:16:01 by inFinie
I see, it must have been corrupted when this site was down, I will upload a new attachment as soon as I get to my other PC which should be tonight with any luck ;)

Thanks for your consideration.
Posted on 2004-08-28 12:33:34 by drarem
Zipped below is the source, I realized I need to restructure the entire process when I attempted to batch the sprite/tile animation - this is one thing I could use help with - you don't have to be an expert by far but if you are, please keep it simple for me :)

Pseudo code would be fine, block diagrams, or code.
Posted on 2004-09-09 00:46:28 by drarem
id love to help particually with regard to the graphics side as id like to expand my knowladge of direct bitmap manipulation and this may well assist your GDI's gfx-side however i should say im currently working on two project which are both ready for first release so bug reports may disract me for a while (aprrox about 2 week i guess)

Also it'd be easier to work on it if you link worked,hehe :oops:
ill check back wit ya soon
Posted on 2004-12-03 12:45:26 by zincboy
Where is the attachment?
Posted on 2005-03-11 01:22:54 by realvampire
This forum has been hacked so many times, I wont bother uploading it..? if you're or anyone else is seriously interested and don't mind my noobish looking code :)? send me an email - through this message board.

Posted on 2005-03-12 07:36:05 by drarem